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.
App.prototype.initialize = function() {
this.onEnable();
this.entity.on('enable', this.onEnable, this);
};
App.prototype.onEnable = function() {
};
Edit: I actually can’t see in the code base where the entity fires the event but the script component does fire a ‘state’ event.
App.prototype.initialize = function() {
this.onEnable();
this.on('state', this.onStateChanged, this);
};
App.prototype.onStateChanged = function(state) {
};