docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method GetSingletonBuffer

    GetSingletonBuffer<T>(bool)

    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.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[] { typeof(BurstCompatibleBufferElement) })]
    public DynamicBuffer<T> GetSingletonBuffer<T>(bool isReadOnly = false) where T : unmanaged, IBufferElementData
    Parameters
    Type Name Description
    bool isReadOnly

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

    Returns
    Type Description
    DynamicBuffer<T>

    The singleton buffer.

    Type Parameters
    Name Description
    T

    The buffer element type.

    Remarks

    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.

    Exceptions
    Type Condition
    InvalidOperationException
    See Also
    GetSingletonEntity()
    GetSingleton<T>()
    In This Article
    • GetSingletonBuffer<T>(bool)
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)