Events
Artificer has numerous events you can subscribe to to allow you to monitor the assembly and dismantling animations and then have you own code do things at various points in those animations. This great for playing particle systems as parts build or triggering a sound effect when a piece is positioned etc.
If you don't want to use events then check the Placing section for how to use a custom class to get even more info for each element.
Static Events
There are three static event types you can subscribe to:
PlacedEvent - This will be invoked when artificer has placed an element whose id is in the placeEvents selection.
BuiltEvent - This will be invoked when the Artificer object has been fully built
DismantledEvent - This will be invoked when the artificer object has been fully dismantled.
As well as the three static events each Artificer object has five events of its own you can listen to, they work pretty much the same as the static events both types have been included as it may suit some projects better to listen to a static event. You can add your own listeners from your own scripts or add them in the Artificer inspector.
Below is a simple example class that will add listeners to the various events
ArtificerBuiltEvent
Event that is invoked when the artificer object completes the building animation. The listener will get the Artificer object passed to it when the event fires. The definition of this event is:
public class ArtificerBuiltEvent : UnityEvent<Artificer> {}ArtificerPlacedEvent
The event will be invoked when an element id that is in the place event selection is positioned. The listener will get the Artificer object as well as the id of the element that has been placed. Your code can use this id to control what happens. Ids for elements can be found by using the Highlighting system in the Artificer Inspector. The definition of the event is:
public class ArtificerPlacedEvent : UnityEvent<Artificer, int> { }ArtificerDismantledEvent
Event that is invoked when the artificer object completes the dismantling animation. The listener will get the Artificer object passed to it when the event fires. The definition of this event is:
ArtificerDismantleEvent
The event will be invoked when an element id that is in the dismantle event selection is fully removed. The listener will get the Artificer object as well as the id of the element that has been removed. Your code can use this id to control what happens. Ids for elements can be found by using the Highlighting system in the Artificer Inspector. The definition of the event is:
ArtificerCompletedObjectEvent
If the Artificer object you are building has multiple GameObjects in it then this event will be invoked when the final element of that gameobject has been placed. The object will need to be in the completed object list in the Artificer inspector. The listener will get the Artificer object as well as the GameObject that has been completed. The definition of the event is:
Last updated