If I have a number of event listeners added:
this.entity.element.on('mouseout',this.onMouseOut,this); this.entity.element.on('mousedown',this.onMouseDown,this); this.entity.element.on('mouseup',this.onMouseUp,this);
How can I effectively remove these on entity.destroy?
I had set up the following:
…with the content of onDestroy performing the following:
this.entity.element.off('mouseout',this.onMouseOut,this); this.entity.element.off('mousedown',this.onMouseDown,this); this.entity.element.off('mouseup',this.onMouseUp,this);
However, the ‘destroy’ event comes AFTER the entity has been destroyed, and element has been removed, so this.entity.element is null, and I can;t access it to kill those listeners.
is the equivalent of entity.element.off() called during destroy? i.e. do I even need to manually remove my listeners which were added using the PlayCanvas event API, or does the framework tidy these up automagically?