afk
November 30, 2017, 3:31am
#1
I’m trying to clone a object I have on the scene with the following code:
const tile = this.prefab.clone();
this.prefab.parent.addChild(tile);
And then firing up a function in one of the object scripts like this:
tile.script.tileComponent.setTile({
tile: cell,
column,
row,
margin,
delayFactor: 0.2,
});
I manage to clone the object but the new object doesn’t have the script attributes from the original prefab
This worked a couple of days ago so I don’t know If there was an API change for deep cloning an object or something else I’m missing.
afk
November 30, 2017, 3:48am
#2
I think what is happening is that the new cloned object is not calling the Initialize method, is there any way I can force it ?
vaios
November 30, 2017, 4:12am
#3
Would you be able to provide a simple reproducible project so we can check it out?
This is exactly my issue, and it happens when cloning disabled objects.
I opened a bug report on GitHub and I’d need a bit of support to find a solution:
vaios
April 23, 2018, 4:18pm
#5
Guys we have pushed a fix for this in the Engine’s master
branch. Would you be able to test if this fixes the issues you mentioned? You can follow the steps here to run with the master engine: https://developer.playcanvas.com/en/user-manual/scripting/custom_engine/
Thanks!
1 Like
I’ll test it asap (max by tomorrow). Thanks!
1 Like
Yes I confirm that until 1.0.0 the script values were uninitialized until the cloned entity gets enabled.
In the last release 1.0.1 it works as expected, right after cloning.
Thanks!