docs.unity.cn
    Show / Hide Table of Contents

    Property Item

    Item[Entity]

    Gets the IComponentData instance of type T for the specified entity.

    Declaration
    public T this[Entity entity] { get; set; }
    Parameters
    Type Name Description
    Entity entity

    The entity.

    Property Value
    Type Description
    T

    An IComponentData type.

    Remarks

    You cannot use ComponentDataFromEntity to get zero-sized IComponentData. Use HasComponent(Entity) to check whether an entity has the zero-sized component instead.

    Normally, you cannot write to components accessed using a ComponentDataFromEntity instance in a parallel Job. This restriction is in place because multiple threads could write to the same component, leading to a race condition and nondeterministic results. However, when you are certain that your algorithm cannot write to the same component from different threads, you can manually disable this safety check by putting the [NativeDisableParallelForRestrictions] attribute on the ComponentDataFromEntity field in the Job.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if T is zero-size.

    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Wednesday, July 6, 2022
    Terms of use