Skip to main content

OnDestroyEvent

A class in Root.Township, the global namespace.

Fires a Unity event when its entity is destroyed, on the sides you pick. Also fires when the entity is unloaded.

Constructors​

MemberWhat it is
OnDestroyEvent()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private AltaEvent destroyEventEvent to fire.
private bool isCallingInLocalTestFire in local test.
private bool isCallingOnClientFire on clients.
private bool isCallingOnServerFire on the server.
private bool isUsingUnityDestroyIf true, fires from Unity's OnDestroy, when child objects are already gone, instead of the scene destroy event.

Methods​

MemberWhat it is
override void Initialize()Hooks the entity's scene destroy event, unless using Unity's destroy.
3 private and internal methods
MemberWhat it is
private void Destroyed()Fires the event if this side is enabled.
private void EntityDestroyedByScene(NetworkEntity entity, bool isUnload)Calls Destroyed when the scene destroys or unloads the entity.
private void OnDestroy()Calls Destroyed if using Unity's destroy.