it seems that initialize, onEnable, onDisable is called multiple times when enable/disabling from inside another initialize/onEnable/onDisable function. We are also getting onDisable call on component even if the entity has not get a onEnable call.
It’s possible that there might be a bug lurking there but we do not actively support the legacy scripting system at the moment. The new scripting system has different mechanisms for this sort of thing. Is it possible for you to use the new scripts? Note you can’t change an existing project to the new scripts you have to make a new project.
Unfortunately it is not possible for us because the new scripting system is not supporting version control and we are a big team working on it and the version control is a must have.
I think I’ve just hit this bug too. My initialize script is being called 17 times, and it seems to have something to do with enabling/disabling entities.
I too am on the legacy scripting system, because I am doing a test prototype, and we will need version control as well should we move forwards.
Do you have a path forwards yet? New scripting system with GItHub integration?
We have ported everything to scripting 2.0. We have a local setup with version control. We have a gulp process that is generating the concatonned gamescript.js to test locally. When we have change to do in playcanvas editor, we drag and drop all updated local scripts into playcanvas and do our changes and do a publish/download to update our local setup.
But, it seems that component event are still bugged with 2.0. We added boolean check everywhere.
Thanks for the info @dracine! I’ve just ported my little prototyping project to scripting 2 as well. I’m only getting 6 now instead of 17, and things are running acceptably, but it’s still a bit strange. I only have the script linked to a single entity, so it’s nothing like that. It’s just getting executed 6 times.