clone numbers for components
parent
b042b797d0
commit
aa574574a6
|
@ -32,6 +32,8 @@ GameLib.Component = function(
|
|||
|
||||
this.linked = false;
|
||||
|
||||
this.cloneNumber = 0;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(delayed)) {
|
||||
delayed = false;
|
||||
}
|
||||
|
@ -403,18 +405,11 @@ GameLib.Component.prototype.clone = function() {
|
|||
|
||||
var apiObject = this.toApiObject();
|
||||
|
||||
this.cloneNumber += 1;
|
||||
|
||||
apiObject.id = GameLib.Utils.RandomId();
|
||||
|
||||
var matches = apiObject.name.match(/Clone \((\d+)\)/);
|
||||
|
||||
if (matches && matches.length > 1) {
|
||||
if (matches.length === 2) {
|
||||
var number = Number(matches[1]);
|
||||
apiObject.name = apiObject.name.replace(/Clone \(\d*\)/, 'Clone (' + (number+1) + ')');
|
||||
}
|
||||
} else {
|
||||
apiObject.name = apiObject.name + ' Clone (1)'
|
||||
}
|
||||
apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')';
|
||||
|
||||
var runtimeObject = null;
|
||||
|
||||
|
@ -436,6 +431,9 @@ GameLib.Component.prototype.clone = function() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO check below event emit
|
||||
*/
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.COMPONENT_CREATED,
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue