realvirtualBehavior Lifetime Methods
When you inherit from realvirtualBehavior in your scripts, the realvirtualController automatically invokes several core lifecycle methods at key moments. This mechanism ensures a consistent flow for starting, stopping, and updating your simulation logic.
Overview of Methods
AwakeAlsoDeactivated()
Called by realvirtualController in its own
Awake()
method.Runs even if the
realvirtualBehavior
component (or its GameObject) is not active.Ideal for any early setup logic that normally would run in
Awake()
, but needs to occur even if disabled.
PreStartSim()
Called once realvirtualController is ready to start the simulation.
Use this to finalize any pre-simulation configuration, such as resetting positions or clearing caches.
StartSim()
Immediately after PreStartSim().
Begin your runtime logic here—start animations, open connections, spawn objects, etc.
StopSim()
Called when the simulation is being paused or stopped (for instance, via the pause button).
Ideal for halting coroutines, stopping movements, and closing any active connections.
Typical Flow
realvirtualController.Awake()
Calls
AwakeAlsoDeactivated()
on everyrealvirtualBehavior
.
realvirtualController.Start()
Eventually calls
StartSim()
(after runningPreStartSim()
).
realvirtualController.Pause() / StopSim()
Invokes
StopSim()
on everyrealvirtualBehavior
.
Here’s a simplified timeline:
Example Script
Below is an example of how you might extend realvirtualBehavior
to respond to these calls:
When to Use These Methods
AwakeAlsoDeactivated()
Use for setting references or configuration that must exist regardless of the GameObject’s active state.
Useful for bridging dependencies or preparing data needed by other scripts.
PreStartSim()
Use for last-minute preparation just before the simulation becomes “live.”
E.g., ensuring internal caches or object pools are ready, resetting the environment, etc.
StartSim()
Your “go” signal for the main logic—starting animations, enabling physics-based behaviors, or beginning timers.
StopSim()
Graceful shutdown: stopping animations, saving states, cleaning up.
Called when the user pauses, or the simulation is otherwise halted by realvirtualController.
Debugging with DebugMode
By enabling DebugMode on the realvirtualController, you will see logs in the Unity console showing precisely when each of these methods is invoked. This is an excellent way to confirm:
Whether your scripts are receiving these calls in the expected order.
If certain scripts remain disabled and thus never receive the calls.
Last updated