docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method SetEnabled

    SetEnabled(Entity, bool)

    Adds or removes the Disabled component to an Entity.

    Declaration
    public void SetEnabled(Entity entity, bool enabled)
    Parameters
    Type Name Description
    Entity entity

    The entity to enable or disable

    bool enabled

    True if the entity should be enabled

    Remarks

    Entities with the Disabled component are not matched by any EntityQuery, and are therefore not processed by systems. To override this behavior for a specific query, use EntityQueryOptions.IncludeDisabledEntities at query creation time.

    If the entity was converted from a prefab and thus has a LinkedEntityGroup component, the entire group will be enabled or disabled.

    This operation requires a structural change to add or remove the Disabled component. To enable or disable individual components without requiring a structural change, see IEnableableComponent and SetComponentEnabled<T>(SystemHandle, bool).

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    See Also
    IsEnabled(Entity)
    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)