Hey guys!
Is there any comprehensive list of built-in PlayCanvas events? Sometimes in tutorials I could see some of them being used, but couldn’t find a full reference unfortunately. Only input events have their constants defined in pc.*, but I know there are much more of them!
There is no list with all the events at the moment. If you go the to API reference http://developer.playcanvas.com/en/api/ you can see the events raised by each class but you have to click on the class you’re interested in. We can definitely improve this I think. Is there anything in particular you’re interested in at the moment?
Thanks, vaios. I was specifically interested in trigger volume events, so I was happy to have found them in the CollisionComponent reference. Another important ones I think are app-related events, like window resizing, adding / removing entities from the hierarchy, changing script attributes, etc. Would be great to find them all in one place!
The application currently does not fire a lot of events and some of them are likely to change. Some of them are:
- preload:start
- preload:progress
- preload:end
- start
- prerender
- update
- frameend [recently called “frameEnd”]
There is a ‘resize’ event on the application’s graphicsDevice. There are currently no events for adding / remove entities from the hierarchy.
For script attributes you can add a method in your script which is called when script attributes change from the Editor:
onAttributeChanged(name, oldValue, newValue)
Also you can subscribe to the ‘set’ event on the script instance which has the same signature with the onAttributeChanged method. e.g.
this.on('set', this.onAttributeChanged, this);
This is fired when another script for example, changes the value of this script’s attributes.
Thanks, that will definitely help me in the future!
A list of all events in the Docu would definitly help a lot!
The mains ones are here: Application Lifecycle | Learn PlayCanvas
Others that are fired are documented in the API docs. Eg for the asset registry, there’s a section for events: AssetRegistry | PlayCanvas API Reference