Available Events¶
DefaultExecutionOrder Attribute¶
In our WASM implementation, the [DefaultExecutionOrder] attribute only affects ordering inside the VM, not Unity's native script order.
It guarantees ordering only among WasmBehaviours, including when multiple behaviours receive the same event.
Example:
1 2 3 4 5 6 7 8 9 10 | |
1 2 3 4 5 6 7 8 9 10 | |
Unity Events¶
| Signature | Description |
|---|---|
| void Awake() | Called when the script instance is loaded. |
| void Start() | Called before the first frame update, after all Awake calls. |
| void Update() | Called once per frame. |
| void LateUpdate() | Called once per frame after all Update calls. |
| void FixedUpdate() | Called on a fixed timestep for physics updates. Note: In ChilloutVR, fixedDeltaTime scales with refresh rate (30–144 Hz). The rate varies, but the timestep remains consistent. |
| void OnCollisionEnter(Collision c) | Called when collision starts. |
| void OnCollisionStay(Collision c) | Called every frame while colliding. |
| void OnCollisionExit(Collision c) | Called when collision ends. |
| void OnTriggerEnter(Collider other) | Called when another collider enters this trigger. |
| void OnTriggerStay(Collider other) | Called every frame while inside this trigger. |
| void OnTriggerExit(Collider other) | Called when a collider exits this trigger. |
Special Execution Order Events¶
| Signature | Description |
|---|---|
| void PostFixedUpdate() | Runs after all Unity and scene FixedUpdate calls. |
| void PostUpdate() | Runs after all Unity and scene Update calls. |
| void PostLateUpdate() | Runs after all Unity and scene LateUpdate calls. |
These events run after all corresponding Unity calls, including scripts outside your VM.
For example, sampling a player's position is most accurate in the PostLateUpdate event, as local Avatar IK and Network IK will have been applied by then.
Gotcha, Scene Execution Order¶
Unity processes script execution order on a per-scene basis. When multiple scenes are loaded additively, the configured execution order is applied in full for each scene individually, not across all scenes at once.
See Unity Documentation for reference.
This means that even with PostFixedUpdate, PostUpdate, and PostLateUpdate, you need to consider which scene your scripts belong to and what they are trying to run after. For the vast majority of use cases, this behaviour will not be something you need to necessarily think about, but do keep it in mind.
For example:
-
World Scene (active)
- Runs
FixedUpdate - Runs
Update - Runs
LateUpdate
- Runs
-
Remote Avatars/Props/Portals Scene (additive)
- Runs
FixedUpdate - Runs
Update - Runs
LateUpdate
- Runs
-
Local Avatar & LateEventManager (DontDestroyOnLoad)
- Runs
FixedUpdate - Fires
PostFixedUpdatefor all in order of subscription. - Runs
Update - Fires
PostUpdatefor all in order of subscription. - Runs
LateUpdate - Fires
PostLateUpdatefor all in order of subscription.
- Runs
World evaluates -> Remote Avatars/Props evaluate -> Local Avatar & Late Events evaluate.
Player Events¶
For Player related APIs see: Player API and LocalPlayer API
| Signature | Description |
|---|---|
| void OnPlayerJoined(Player player) | Player joins (local included). |
| void OnPlayerLeft(Player player) | Player leaves (local included). |
| void OnPlayerRespawned(Player player) | Player respawns. |
| void OnPlayerTriggerEnter(Player player) | Player enters this trigger. |
| void OnPlayerTriggerStay(Player player) | Player remains in this trigger. |
| void OnPlayerTriggerExit(Player player) | Player exits this trigger. |
| void OnPlayerCollisionEnter(Player player) | Collision with a player begins. |
| void OnPlayerCollisionStay(Player player) | Player remains in collision. |
| void OnPlayerCollisionExit(Player player) | Collision with a player ends. |
Prop Events¶
For Prop related APIs see: Prop API
| Signature | Description |
|---|---|
| void OnPropSpawned(Prop prop) | Prop spawned in instance. |
| void OnPropDespawned(Prop prop) | Prop despawned. |
| void OnPropTriggerEnter(Prop prop, Collider other) | Prop enters this trigger. |
| void OnPropTriggerStay(Prop prop, Collider other) | Prop remains in this trigger. |
| void OnPropTriggerExit(Prop prop, Collider other) | Prop exits this trigger. |
| void OnPropCollisionEnter(Prop prop, Collision c) | Prop collision begins. |
| void OnPropCollisionStay(Prop prop, Collision c) | Prop remains colliding. |
| void OnPropCollisionExit(Prop prop, Collision c) | Prop collision ends. |
Portal Events¶
For Portal related APIs see: Portal API
| Signature | Description |
|---|---|
| void OnPortalCreated(Portal portal) | Portal was created. |
| void OnPortalDestroyed(Portal portal) | Portal was destroyed. |
Networking Events¶
For Networking related APIs see: Networking API
| Signature | Description |
|---|---|
| void OnInstanceOwnerChange(Player newOwner) | Invoked whenever the instance ownership changes. |
| void OnNetworkMessageReceived(Player sender, Span |
Invoked whenever a message is received. You must explicitly subscribe to this in the Networking API. |