# HasSingleton<T>()

> Checks whether a singleton component of the specified type exists.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

```csharp
public static bool HasSingleton<T>() where T : unmanaged
```

### Returns

| Type                                                          | Description                                                                                                                        |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True, if a singleton of the specified type exists in the current [World](/engine/7000.0/script-reference/unity/entities/world.md). |

### Remarks

The [SystemAPI](/engine/7000.0/script-reference/unity/entities/systemapi.md) singleton methods build their query with the default [EntityQueryOptions](/engine/7000.0/script-reference/unity/entities/entityqueryoptions.md) flags, which exclude entities that have the [Disabled](/engine/7000.0/script-reference/unity/entities/disabled.md) component and entities that have the [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md) component. So if the only entity that has component `T` is disabled or is an entity prefab, this method returns false, and [SystemAPI.GetSingleton](/engine/7000.0/script-reference/unity/entities/systemapi/getsingleton.md) throws an exception.

To find a singleton component on a disabled entity or on an entity prefab, create an [EntityQuery](/engine/7000.0/script-reference/unity/entities/entityquery.md) with the [EntityQueryOptions.IncludeDisabledEntities](/engine/7000.0/script-reference/unity/entities/entityqueryoptions/includedisabledentities.md) or [EntityQueryOptions.IncludePrefab](/engine/7000.0/script-reference/unity/entities/entityqueryoptions/includeprefab.md) option, then call [EntityQuery.HasSingleton](/engine/7000.0/script-reference/unity/entities/entityquery/hassingleton.md) on that query.

Not working in Entities.ForEach, IJobEntity, and Utility methods
