docs.unity.cn
    Show / Hide Table of Contents

    Struct SharedComponentTypeHandle<T>

    A handle to a specific shared component type, used to access an ArchetypeChunk's component data in a job.

    Namespace: Unity.Entities
    Syntax
    [NativeContainer]
    [NativeContainerIsReadOnly]
    public struct SharedComponentTypeHandle<T>
        where T : struct, ISharedComponentData
    Type Parameters
    Name Description
    T

    Shared component type.

    Remarks

    Passing a type handle to a job automatically registers the job as a reader or writer of that type, which allows the DOTS safety system to detect potential race conditions between concurrent jobs which access the same component type.

    To create a SharedComponentTypeHandle, use GetSharedComponentTypeHandle<T>(). While type handles can be created just in time before they're used, it is more efficient to create them once during system creation, cache them in a private field on the system, and incrementally update them with Update(SystemBase) just before use.

    If the component type is not known at compile time, use DynamicSharedComponentTypeHandle.

    Methods

    Name Description
    ToFixedString()

    Returns the formatted FixedString "SharedComponentTypeHandle[type_name_here]".

    Update(SystemBase)

    When a SharedComponentTypeHandle is cached by a system across multiple system updates, calling this function inside the system's OnUpdate() method performs the minimal incremental updates necessary to make the type handle safe to use.

    Update(ref SystemState)

    When a SharedComponentTypeHandle is cached by a system across multiple system updates, calling this function inside the system's OnUpdate() method performs the minimal incremental updates necessary to make the type handle safe to use.

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023