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

EntityQuery.GetSingletonBuffer

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 DynamicBuffer<T> GetSingletonBuffer(bool isReadOnly);

Parameters

Parameter Description
isReadOnly If the caller does not need to modify the buffer contents, pass true here.

Returns

DynamicBuffer<T> The singleton buffer.

Description

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

A singleton buffer component is a component of which only one instance exists that satisfies this query. There is no SetSingletonBuffer(); to change the contents of a singleton buffer, pass isReadOnly=false to GetSingletonBuffer() and then modify the contents directly.

Additional resources: EntityQuery.GetSingletonEntity, ComponentSystemBase.GetSingleton