docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method AddComponent

    AddComponent<T>(GameObject)

    Adds a component to the game object and registers an undo operation for this action.

    Declaration
    public T AddComponent<T>(GameObject gameObject) where T : Component
    Parameters
    Type Name Description
    GameObject gameObject

    The game object you want to add the component to.

    Returns
    Type Description
    T

    The new component.

    Type Parameters
    Name Description
    T

    The type of component you want to add.

    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)