HasSingleton<T>()
Checks whether a singleton component of the specified type exists.
Read time 1 minuteLast updated a day ago
Definition
- Type: Method
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
public static bool HasSingleton<T>() where T : unmanaged
Returns
Remarks
The SystemAPI singleton methods build their query with the default EntityQueryOptions flags, which exclude entities that have the Disabled component and entities that have the Prefab component. So if the only entity that has component is disabled or is an entity prefab, this method returns false, and SystemAPI.GetSingleton throws an exception.
TTo find a singleton component on a disabled entity or on an entity prefab, create an EntityQuery with the EntityQueryOptions.IncludeDisabledEntities or EntityQueryOptions.IncludePrefab option, then call EntityQuery.HasSingleton on that query.
Not working in Entities.ForEach, IJobEntity, and Utility methods