It happens if I load a new scene to an existing scene, so not to sure if I can reproduce Today I fixed many with ‘find in files’ and ‘replaced all’. Before xmas the code was (mostly) working, today the same code with no changes not
Most common is:
root (exsisting Scene)
|-> root (added Scene)
(Has been best working design for multiscene till now)
But the example with the Cam was the first to be noticed by me.
Made a very simple demo to show the error: Test double name in hirarchy tree
-the script in scenemanager init access wrong entity
-script onPress for button works well
but its the same line of code ?
that was only a sample to show
It’s more a generel problem. I’ve nearly 500 scripts in my project an more than a thousand line of code with this issue.
In the small example, when testing in chrome browser, the top camera will be disabled If I enable it via editor the cam is on again.
I think the best I can do is rename all entitys with double names to have everything reliable working…
I was just wondering if something with PlayCanvas has changed, becouse behaviour has changed servere
Interesting. It looks like findByName returns itself if the name matches
findByName: function (name) {
if (this.name === name) return this;
for (var i = 0; i < this._children.length; i++) {
var found = this._children[i].findByName(name);
if (found !== null) return found;
}
return null;
},
This looks intentional and unlikely to be changed.
Assuming that the second name is a direct child underneath the first, you can use:
findByName: function (name) {
for (var i = 0; i < this._children.length; i++) {
var found = this._children[i].findByName(name);
if (found !== null) return found;
}
if (this.name === name) return this;
else return null;
},
?