I was trying out an application which needed some library JS files. But didn’t get an expected result. I read somewhere on the forum to create a new script in the editor itself and copy paste the library content and place in “Script Order”. But no luck. (I had asked this question in answers.playcanvas.com - http://answers.playcanvas.com/questions/3025/script-loading-order-error). However, I found the scripts to come in order when I attach them to an entity. All worked great till now.
(I noticed the new editor updates the scene on script update - Great feature though).
Now when I try to update a particular script, it comes to the top of the order as seen in Inspector(Chrome 51) which eventually generates errors in run-time. Would be great if somebody could help me out with the process of script execution order or on how playcanvas handles it. Any kind of help is truly appreciated.
Thanks.
PS: Loading Order in the old editor is working fine. Problems only with the new editor
script loading order still doesn’t work as expected for me.
campGame should run before campUIbarbutton,
I’ve put console.log in both of the initialize methods, and campUIbarbutton always shows up first…
I need campGame to function as a singleton, sort of, but if I can’t rely on the order, then I can’t be sure the singleton exists in other objects’ initialize, which is annoying.
am I doing something wrong or misundestanding? or is it just buggy…
Load order is not related to the order/when the initialize function is called.
If you put a console.log at the top of each file, you should see that they are loaded in the correct order. The order that the initialize function is called is dependent on the entity hierarchy and when entities are enabled.