docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IDebugOnAdded

    Implement this interface on a component type to receive a callback when Unity adds that component to an entity.

    Namespace: Unity.Entities
    Assembly: Unity.Entities.dll
    Syntax
    public interface IDebugOnAdded
    Remarks

    A component type that implements this interface must also declare a matching callback method:

    public static void OnAdded(Entity entity, in T component)
    

    where T is the component type. The method must be public and static, must return void, and must take an Entity followed by an in parameter of the component's own type.

    Unity calls the callback once for each entity that the component is added to. Unity doesn't call the callback when you create an entity that already has the component, for example from an archetype that includes it. Unity compiles the callback into the Editor and into development builds, and excludes it from release builds.

    Set a breakpoint in the callback to inspect the call stack and check what added the component.

    For more information, refer to Component lifecycle callbacks.

    See Also

    IDebugOnRemoved
    In This Article
    Back to top
    Copyright © 2026 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)