docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GameObjectExtensions

    Useful methods for GameObjects.

    Inheritance
    object
    GameObjectExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Muse.Behavior
    Assembly: Unity.Muse.Behavior.dll
    Syntax
    public static class GameObjectExtensions

    Methods

    GetOrAddComponent<T>(GameObject)

    Gets or adds a component to a GameObject.

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

    the gameObject targeted

    Returns
    Type Description
    T

    The requested component type, either already on the GameObject or created and added within this method.

    Type Parameters
    Name Description
    T

    The type of the component required

    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)