# SetSingleton<T>(T)

> Sets the value of a singleton component. Note that if querying a singleton component from a system-associated entity, the query must include either EntityQueryOptions.IncludeSystems or the SystemInstance component.

## Definition

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

```csharp
public void SetSingleton<T>(T value) where T : unmanaged, IComponentData
```

### Parameters

**** (T): An instance of type T containing the values to set.

### Remarks

For a component to be a singleton, there can be only one instance of that component that satisfies this query.

**Note:** singletons are otherwise normal entities. The EntityQuery and [ComponentSystemBase](/engine/7000.0/script-reference/unity/entities/componentsystembase.md) singleton functions add checks that you have not created two instances of a type that can be accessed by this singleton query, but other APIs do not prevent such accidental creation.

To create a singleton, create an entity with the singleton component.

For example, if you had a component defined as:

You could create a singleton as follows:

To update the singleton component after creation, you can use an EntityQuery object that selects the singleton entity and call this `SetSingleton()` function:

You can set and get the singleton value from a system: see [ComponentSystemBase.SetSingleton](/engine/7000.0/script-reference/unity/entities/componentsystembase/setsingleton.md) and [ComponentSystemBase.GetSingleton](/engine/7000.0/script-reference/unity/entities/componentsystembase/getsingleton.md).

Additional Resources: [EntityQuery.GetSingleton](/engine/7000.0/script-reference/unity/entities/entityquery/getsingleton.md), [EntityQuery.GetSingletonEntity](/engine/7000.0/script-reference/unity/entities/entityquery/getsingletonentity.md)
