docs.unity.cn
    Show / Hide Table of Contents

    Method SetComponentEnabled

    SetComponentEnabled(ref DynamicComponentTypeHandle, Int32, Boolean)

    Enable or disable a IComponentData on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.

    Declaration
    public readonly void SetComponentEnabled(ref DynamicComponentTypeHandle typeHandle, int entityIndexInChunk, bool value)
    Parameters
    Type Name Description
    DynamicComponentTypeHandle typeHandle

    A type handle for the component type that will be enabled or disabled.

    Int32 entityIndexInChunk

    The index within this chunk of the entity whose component should be checked.

    Boolean value

    True if the specified component should be enabled, or false if it should be disabled.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    ArgumentException

    The target component type is not present in the this chunk.

    SetComponentEnabled<T>(ref ComponentTypeHandle<T>, Int32, Boolean)

    Enable or disable a IComponentData on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.

    Declaration
    public readonly void SetComponentEnabled<T>(ref ComponentTypeHandle<T> typeHandle, int entityIndexInChunk, bool value)
        where T : IComponentData, IEnableableComponent, new()
    Parameters
    Type Name Description
    ComponentTypeHandle<T> typeHandle

    A type handle for the component type that will be enabled or disabled.

    Int32 entityIndexInChunk

    The index within this chunk of the entity whose component should be checked.

    Boolean value

    True if the specified component should be enabled, or false if it should be disabled.

    Type Parameters
    Name Description
    T

    The component type to enable or disable. This type must implement the IEnableableComponent interface.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    ArgumentException

    The target component type T is not present in the this chunk.

    See Also
    IsComponentEnabled<T>(ref ComponentTypeHandle<T>, Int32)

    SetComponentEnabled<T>(ComponentTypeHandle<T>, Int32, Boolean)

    Obsolete. Use SetComponentEnabled<T>(ref ComponentTypeHandle<T>, Int32, Boolean) instead.

    Declaration
    [Obsolete("The typeHandle argument should now be passed by ref. (RemovedAfter Entities 1.0)", false)]
    public readonly void SetComponentEnabled<T>(ComponentTypeHandle<T> typeHandle, int entityIndexInChunk, bool value)
        where T : IComponentData, IEnableableComponent, new()
    Parameters
    Type Name Description
    ComponentTypeHandle<T> typeHandle

    A type handle for the component type that will be enabled or disabled.

    Int32 entityIndexInChunk

    The index within this chunk of the entity whose component should be checked.

    Boolean value

    True if the specified component should be enabled, or false if it should be disabled.

    Type Parameters
    Name Description
    T

    The component type to enable or disable. This type must implement the IEnableableComponent interface.

    SetComponentEnabled<T>(ref BufferTypeHandle<T>, Int32, Boolean)

    Enable or disable a IBufferElementData on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.

    Declaration
    public readonly void SetComponentEnabled<T>(ref BufferTypeHandle<T> bufferTypeHandle, int entityIndexInChunk, bool value)
        where T : struct, IBufferElementData, IEnableableComponent
    Parameters
    Type Name Description
    BufferTypeHandle<T> bufferTypeHandle

    A type handle for the buffer component type that will be enabled or disabled.

    Int32 entityIndexInChunk

    The index within this chunk of the entity whose buffer component should be checked.

    Boolean value

    True if the specified buffer component should be enabled, or false if it should be disabled.

    Type Parameters
    Name Description
    T

    The buffer component type to enable or disable. This type must implement the IEnableableComponent interface.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    ArgumentException

    The target component type T is not present in the this chunk.

    InvalidOperationException

    bufferTypeHandle was created as read-only (in-Editor only, if the Jobs Debugger is enabled.

    See Also
    IsComponentEnabled<T>(ref BufferTypeHandle<T>, Int32)

    SetComponentEnabled<T>(BufferTypeHandle<T>, Int32, Boolean)

    Obsolete. Use SetComponentEnabled<T>(ref BufferTypeHandle<T>, Int32, Boolean) instead.

    Declaration
    [Obsolete("The bufferTypeHandle argument should now be passed by ref. (RemovedAfter Entities 1.0)", false)]
    public readonly void SetComponentEnabled<T>(BufferTypeHandle<T> bufferTypeHandle, int entityIndexInChunk, bool value)
        where T : struct, IBufferElementData, IEnableableComponent
    Parameters
    Type Name Description
    BufferTypeHandle<T> bufferTypeHandle

    A type handle for the buffer component type that will be enabled or disabled.

    Int32 entityIndexInChunk

    The index within this chunk of the entity whose buffer component should be checked.

    Boolean value

    True if the specified buffer component should be enabled, or false if it should be disabled.

    Type Parameters
    Name Description
    T

    The buffer component type to enable or disable. This type must implement the IEnableableComponent interface.

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