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

ComponentManager

ComponentManager

class ComponentManager
Manages component registration, creation, and lifecycle in the Spatial SDK.
The ComponentManager is responsible for:
  • Registering components with the system
  • Creating component instances
  • Managing component pools
  • Tracking attribute information for components
  • Handling entity component lifecycle
How to register a component in your Spatial SDK Activity/Service:
override fun onCreate() {
  super.onCreate()
  componentManager.registerComponent<MyComponent>(MyComponent.Companion)
}

Constructors

NameSummary
ComponentManager
constructor()

Functions

NameSummary
assertComponent
fun assertComponent(clazz: KClass<*>)

Asserts that a component class is registered.
checkComponent
fun checkComponent(clazz: KClass<*>): Boolean

Checks if a component class is registered.
createInstance
fun <T> createInstance(clazz: KClass<>): <Error class: unknown class><T, Boolean>

Creates an instance of a component without associating it with an entity.



fun <T> createInstance(clazz: KClass<
>, entID: Long): <Error class: unknown class><T, Boolean>

Creates an instance of a component for a specific entity.
registerComponent
inline fun <T : ComponentBase> registerComponent(companionObjectInstance: ComponentCompanion, sendRate: SendRate = SendRate.DEFAULT)

Registers a component with the ComponentManager using reified type parameters.



fun registerComponent(clazz: KClass<*>, name: String, sendRate: SendRate, companionObjectInstance: ComponentCompanion)

This method registers a component class with the ComponentManager, making it available for use with entities. It also registers the component’s attributes with the DataModel and configures metadata settings.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon