Yeah, I read that in the above post, but I can’t seem to get it triggering even when it’s enabled later on having already been disabled. The event is just called ‘enable’ right? and I attach it to the entity?
There is an event that is fired (surprised it isn’t in the documentation). However, if an entity starts off disabled, the initialize function of the scripts attached are not called. It gets called on the first time the pc.script gets enabled.
So the way around this is to call the callback in the initialize function and also subscribe to the event.
In this case, if an entity is starts enabled, wouldn’t that result in the onEnable() method being called twice?
After all, there may be subscriptions to events, etc. And that’s not good.
The initialize function of script is called after the enable event on the Entity so it will not be called twice. And until the initialize function of the script is called, there is no subscription to events.