Order of execution

This page describes the order of various coherence events and scripts in relation to Unity's main loop.

Script execution order

Check out ScriptExecutionOrder.

Additionally, take a look at your project's Script Execution Order settings by opening Edit > Project Settings and selecting the Script Execution Order category. See this Unity manual article for more details.

Depending on the reason for a disconnection the onDisconnected event can be raised from different places in the code, including LateUpdate.

CoherenceSync instance lifecycle

When a Prefab instance with CoherenceSync is created at runtime, it will be fully synchronized with the network in the OnEnable method of CoherenceSync. This means that you can expect your custom Components to have fully resolved synchronized values and authority state in your Awake method. It occurs in the following order:

CoherenceSync

  1. Awake() is called

    1. Internal initialization.

  2. OnEnable() is called

    1. Synchronize with a new or existing Network Entity.

    2. OnBeforeNetworkedInstantiation event is invoked.

    3. Initial component updates are applied (for entities you have no authority over).

    4. OnNetworkedInstantiation event is invoked.

    5. OnStateAuthority or OnStateRemote (for authority or non-authority instances respectively) event is invoked.

User-defined Components

  1. Awake() is called

    1. At this point, if you get the CoherenceSync component, you can expect networked variables and authority state to be fully resolved.

Last updated