I am trying to get another entity via app.root.findByName(string).
However, I cannot even get app.root in my script.
When I let google chrome output the object “app.root”, I get an object which contains “Root” as a child!
Root itself has all the correct children (all entities of my scene), but I cannot reach it.
Attempting to access or output the children array claims it to be “undefined”, though I can navigate through it within the Chrome Dev Tools.
I’m stuck on a trivial task with inconsistent feedback from the dev environment
Here’s a screenshot from the chrome dev tools, where I can navigate to the Root element which is a child of this undocumented ghost node?
app.root - is actually root of an application, not the scene root.
In order to get scene root, you have to get first child of a app root: app.root.getChildren()[0], then you can get its children.
It is a bit weird I admit, that it creates magical “Untitled” entity as a app root, instead of just referencing scene root.
All sources told me to use app.root.findByName(string), which did not work.
It always gave me 0 results.
I also already tried app.root.getChildren()[0] and received undefined.
Today it works as expected! I did not change the code yet. Could this be some sort of cache problem?
app.root.findByName(‘SocialManager’) now returns the entity I was expecting all the time.
It could be that you were referencing app not the one provided in script create callback.
There is window.app, which is different thing, and only appears in launcher.
There were no changes to engine/editor between yesterday and today. Sometimes good sleep - is a best cure