API reference
API reference
Select your platform
No SDKs available
No versions available

SystemManager Class

Modifiers: final
Manages the lifecycle and execution of systems within the Spatial SDK.
SystemManager is responsible for organizing, prioritizing, and executing systems in a deterministic order based on their dependencies. It maintains a directed acyclic graph (DAG) of systems to ensure proper execution order and handles system registration, discovery, and lifecycle management.
Systems can be registered with different priority groups (EARLY, NORMAL, LATE) to control their relative execution order. The manager ensures systems are executed in topologically sorted order based on their dependencies and priority groups.
Example usage:
// Register a system
systemManager.registerSystem(MyCustomSystem())
// Find a system by class
val avatarSystem = systemManager.findSystem<AvatarSystem>()

The SystemManager is created and managed by AppSystemActivity or other activity classes that extend from VrActivity.

Signature

class SystemManager

Constructors

SystemManager ()
Signature
constructor()

Functions

findSystem ( clazz )
Finds a system by its class.
Signature
fun <T : SystemBase> findSystem(clazz: KClass<T>): T
Parameters
clazz: KClass
  The class of the system to find.
Returns
  The system instance.
Throws
Exception
  if the system is not found.
findSystem ()
Finds a system by its type using reified type parameters.
Signature
inline fun <T : SystemBase> findSystem(): T
Returns
  The system instance.
Throws
Exception
  if the system is not found.
getScene ()
Returns the scene associated with the manager.
Signature
fun getScene(): Scene
Returns
  The associated scene.
registerEarlySystem ( system )
Registers an early system that will be executed before other systems.
Signature
fun registerEarlySystem(system: SystemBase)
Parameters
system: SystemBase
  The early system to register.
registerLateSystem ( system )
Registers a late system that will be executed after other systems.
Signature
fun registerLateSystem(system: SystemBase)
Parameters
system: SystemBase
  The late system to register.
registerSystem ( system )
Adds a system to the manager, which will be called for all operations.
Example usage:
override fun onCreate(savedInstanceState: Bundle?) {
  systemManager.registerSystem(MyCustomSystem())
}

Signature
fun registerSystem(system: SystemBase)
Parameters
system: SystemBase
  The system to add.
setEarlySystems ( earlySystems )
Sets the early systems in the manager.
Early systems are executed before normal priority systems.
Signature
fun setEarlySystems(earlySystems: List<SystemBase>)
Parameters
earlySystems: List
  The early systems to set.
setLateSystems ( lateSystems )
Sets the late systems in the manager.
Late systems are executed after normal priority systems.
Signature
fun setLateSystems(lateSystems: List<SystemBase>)
Parameters
lateSystems: List
  The late systems to set.
tryFindSystem ( clazz )
Tries to find a system by its class.
Signature
fun <T : SystemBase> tryFindSystem(clazz: KClass<T>): T?
Parameters
clazz: KClass
  The class of the system to find.
Returns
  The system instance or null if not found.
tryFindSystem ()
Tries to find a system by its type using reified type parameters.
Signature
inline fun <T : SystemBase> tryFindSystem(): T?
Returns
  The system instance or null if not found.
unregisterSystem ( clazz )
Unregisters a system from the manager.
Example usage:
override fun onCreate(savedInstanceState: Bundle?) {
  // Unregister locomotion system to prevent controller movement
  systemManager.unregisterSystem<LocomotionSystem>()
}

Signature
fun <T : SystemBase> unregisterSystem(clazz: KClass<T>)
Parameters
clazz: KClass
  The class of the system to unregister.
unregisterSystem ()
Unregisters a system by its type using reified type parameters.
Signature
inline fun <T : SystemBase> unregisterSystem()
Did you find this page helpful?