realvirtual Init Sequence
Only Version 6.1.4+
Last updated
Only Version 6.1.4+
Last updated
Unity's default execution order provides a solid foundation for initialization but often lacks the granular control needed for complex scenarios—particularly when integrating third-party solutions, orchestrating sequence events across different GameObjects, or dealing with additive scene loading. To address these challenges, realvirtual introduces an additional initialization sequence managed by the realvirtualController.
By extending Unity’s built-in lifecycle, realvirtual ensures a more predictable and step-by-step setup process across complex multi-scene projects. This is especially helpful for coordinating dependencies among third-party plugins, custom systems, and multi-scene workflows.
The extended lifecycle adds five main phases:
InitStart
InitAwake
InitEnable
InitAllScenesLoaded
InitPostAllScenesLoaded
Each phase is opt-in; you only need to implement the corresponding interface or override the provided method in your scripts.
Debugging Tip You can enable DebugMode on the realvirtualController (e.g., via the Inspector) to see detailed console logs showing the exact sequence of calls. This is especially useful if you need to confirm your InitStart, InitAwake, InitEnable, and InitAllScenesLoaded methods are running at the expected times.
Scene Load (Unity)
realvirtualController Recognition
InitStart → InitAwake → InitEnable → (Additive Scenes Load) → InitAllScenesLoaded → InitPostAllScenesLoaded
Below is a closer look at each phase.
Triggered When: The realvirtualController is first recognized.
Key Tasks:
Reads and applies any saved settings (e.g., DebugMode
, ConnectionMode
from PlayerPrefs
).
Invokes any script that implements the IInitStart
interface.
Triggered When: realvirtualController's standard Awake method is called.
Key Tasks:
Unity’s standard Awake()
can happen before or after this, depending on Unity’s internal ordering.
Use IInitAwake
for additional initialization logic that should pair with Unity’s Awake but be orchestrated by realvirtualController.
Triggered When: realvirtualController is enabled (similar to Unity’s OnEnable()
).
Key Tasks:
Standard OnEnable()
may occur before or after this, again depending on Unity’s internal ordering.
Regardless of the active status of your script derived from realvirtualBehavior
, this will still be called.
Triggered When: All scenes (including additive scenes) have been loaded.
Key Tasks:
If no additional scenes are loaded, this runs immediately after InitEnable
.
Typically used for final cross-scene references or enabling/disabling systems that depend on every scene being ready.
Implement IAllScenesLoaded
or override OnAllScenesLoaded
in your realvirtualBehavior
.
Triggered When: Immediately after InitAllScenesLoaded
.
Key Tasks:
Allows “late-late” initialization logic—when you want to ensure everything in InitAllScenesLoaded
(including other scripts) has completed.
Below is an example of a script that handles multiple phases by implementing multiple interfaces:
InitStartIInitStart
Earliest moment after the realvirtualController is recognized. Useful for reading config or setting global states.
InitAwakeIInitAwake
Pairs with Unity’s Awake()
for orchestrated initialization.
InitEnableIInitEnable
Pairs with Unity’s OnEnable()
, for activation-related logic.
InitAllScenesLoadedIAllScenesLoaded
Ensures all scenes (including additive scenes) are loaded before proceeding. Ideal for cross-scene references.
InitPostAllScenesLoaded
Late-late initialization after all scenes and logic in InitAllScenesLoaded
.