File:Documentation Index
Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
Use this file to discover all available pages before exploring further.
Assets/_Molca/_Core/Runtime/RuntimeSubsystem.csBase for:
ModalManager, ScenarioSessionManager, VRFadeManager, GameManager, TourSubsystem, etc.
When to use
SubclassRuntimeSubsystem when you need a cross-scene service that:
- Must initialize before gameplay code runs (controlled by
InitializationPriority). - Should be registered in the DI container automatically for
[Inject]andGetService<T>resolution. - Needs lifecycle hooks (initialize → activate → deactivate → shutdown) tied to
RuntimeManager.
MonoBehaviour with [Inject] instead.
Lifecycle
Initialize(Action<IRuntimeSubsystem> finishCallback)— must invoke the callback when finished.Activate()/Deactivate()— default togglesisActive.Shutdown()— default callsDeactivate().
RuntimeMode
Serialized flags can restrict a subsystem to Editor and/or Player so tooling components do not run in builds.InitializationPriority
RuntimeManager sorts subsystems in descending order: higher numeric InitializationPriority runs first.
Placement
Add each subsystem once as an enabled child component on the RuntimeManager prefab. Duplicate component types are detected and duplicates removed with a warning.Using from code
API Reference
| Method | Signature | Description |
|---|---|---|
Initialize | abstract void Initialize(Action<IRuntimeSubsystem> finishCallback) | Called by RuntimeManager during bootstrap. Must invoke finishCallback when initialization is complete. RuntimeManager waits up to 20 seconds for the callback. |
Shutdown | virtual void Shutdown() | Called when RuntimeManager is destroyed or application quits. Default implementation calls Deactivate(). Override to clean up resources before base shutdown. |
Activate | virtual void Activate() | Enables the subsystem. Default implementation sets isActive = true. Called after successful initialization. |
Deactivate | virtual void Deactivate() | Disables the subsystem. Default implementation sets isActive = false. Called during shutdown or when subsystem needs to pause. |
OnApplicationPause | virtual void OnApplicationPause(bool pauseStatus) | Unity lifecycle callback forwarded from RuntimeManager. Override to handle application pause/resume events (mobile backgrounding, focus loss). |
OnApplicationQuit | virtual void OnApplicationQuit() | Unity lifecycle callback forwarded from RuntimeManager. Override to perform cleanup before application termination. Called before Shutdown(). |
InitializationPriority | int InitializationPriority { get; set; } | Determines initialization order. Higher values initialize first (descending sort). Set in Inspector or constructor. |
RuntimeMode | RuntimeMode RuntimeMode { get; set; } | Flags controlling whether subsystem runs in Editor and/or Player builds. Use to exclude tooling subsystems from runtime builds. |
isActive | bool isActive { get; protected set; } | Current activation state. Set by Activate() and Deactivate(). Check before performing subsystem operations. |
Troubleshooting
- Subsystem never initializes: ensure
finishCallbackis invoked —RuntimeManagerawaits it with a 20-second timeout. - Subsystem runs in builds but shouldn’t: set
RuntimeModeto Editor on the component to exclude it from player builds. GetSubsystem<T>()returns null: the subsystem must be an enabled child of the RuntimeManager prefab (or registered viaRuntimeManager.RegisterSubsystem).
Unity Editor
