docs.unity3d.com
    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
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023