docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method SetComponentEnabled

    SetComponentEnabled<T>(int, Entity, bool)

    Records a command to enable or disable a ComponentType 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 void SetComponentEnabled<T>(int sortKey, Entity e, bool value) where T : struct, IEnableableComponent
    Parameters
    Type Name Description
    int sortKey

    A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from Execute(in ArchetypeChunk, int, bool, in v128).

    Entity e

    The entity whose component should be enabled or disabled.

    bool 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.

    Remarks

    At playback, this command throws an error if this entity is destroyed before playback, if this entity is still deferred, if the entity has the Prefab tag, or if the entity doesn't have the component type.

    SetComponentEnabled(int, Entity, ComponentType, bool)

    Records a command to enable or disable a ComponentType 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 void SetComponentEnabled(int sortKey, Entity e, ComponentType componentType, bool value)
    Parameters
    Type Name Description
    int sortKey

    A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from Execute(in ArchetypeChunk, int, bool, in v128).

    Entity e

    The entity whose component should be enabled or disabled.

    ComponentType componentType

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

    bool value

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

    Remarks

    At playback, this command throws an error if this entity is destroyed before playback, if this entity is still deferred, if the entity has the Prefab tag, or if the entity doesn't have the component type.

    In This Article
    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)