Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

EntityQuery.HasSingleton

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool HasSingleton();

Returns

bool True, if a singleton is found to match exactly once with the specified typeEntityQuery.

Description

Checks whether a singleton component of the specified type exists. Note that if querying a singleton component from a system-associated entity, the query must include either EntityQueryOptions.IncludeSystems or the SystemInstance component.

This method matches only the entities that this query matches, so the query's EntityQueryOptions determine whether a singleton entity is found. Unless the query uses EntityQueryOptions.IncludeDisabledEntities or EntityQueryOptions.IncludePrefab, entities that have the Disabled component or the Prefab component are excluded, and this method returns false for a singleton on one of those entities.