GetSingletonRW<T>()
Gets a reference to a singleton component, for read/write access. Note that if querying a singleton component from a system-associated entity, the query must include either EntityQueryOptions.IncludeSystems or the SystemInstance component.
Read time 1 minuteLast updated a day ago
Definition
- Type: Method
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
public RefRW<T> GetSingletonRW<T>() where T : unmanaged, IComponentData
Returns
Type | Description |
|---|---|
| RefRW<T> | A reference to the singleton component. |
Remarks
A singleton component is a component of which only one instance exists that satisfies this query.
The reference refers directly to the singleton's component memory. Structural changes to the chunk where the singleton resides can invalidate this reference and result in crashes or undefined behaviour if the reference is used after structural changes.
If safety checks are enabled, this method throws an exception if a job that reads or writes is still running, whereas EntityQuery.GetSingleton throws only if a job that writes is still running. Neither method completes the conflicting job for you. This method also increments the change version of , even if you don't write to the returned reference, so queries that filter on changes to match the singleton entity.
TTTT