mrtk_developmentreleases/2.0.0releases/2.1.0releases/2.2.0

    Show / Hide Table of Contents

    Class ComponentExtensions

    Extensions methods for the Unity Component class. This also includes some component-related extensions for the GameObject class.

    Inheritance
    Object
    ComponentExtensions
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Microsoft.MixedReality.Toolkit
    Assembly: cs.temp.dll.dll
    Syntax
    public static class ComponentExtensions

    Methods

    EnsureComponent(GameObject, Type)

    Ensure that a component of type exists on the game object. If it doesn't exist, creates it.

    Declaration
    public static Component EnsureComponent(this GameObject gameObject, Type component)
    Parameters
    Type Name Description
    GameObject gameObject
    Type component

    A component on the game object for which a component of type should exist.

    Returns
    Type Description
    Component

    The component that was retrieved or created.

    EnsureComponent(GameObject, Type)

    Ensure that a component of type exists on the game object. If it doesn't exist, creates it.

    Declaration
    public static Component EnsureComponent(this GameObject gameObject, Type component)
    Parameters
    Type Name Description
    GameObject gameObject
    Type component

    A component on the game object for which a component of type should exist.

    Returns
    Type Description
    Component

    The component that was retrieved or created.

    EnsureComponent<T>(Component)

    Ensure that a component of type T exists on the game object. If it doesn't exist, creates it.

    Declaration
    public static T EnsureComponent<T>(this Component component)
    
        where T : Component
    Parameters
    Type Name Description
    Component component

    A component on the game object for which a component of type T should exist.

    Returns
    Type Description
    T

    The component that was retrieved or created.

    Type Parameters
    Name Description
    T

    Type of the component.

    EnsureComponent<T>(Component)

    Ensure that a component of type T exists on the game object. If it doesn't exist, creates it.

    Declaration
    public static T EnsureComponent<T>(this Component component)
    
        where T : Component
    Parameters
    Type Name Description
    Component component

    A component on the game object for which a component of type T should exist.

    Returns
    Type Description
    T

    The component that was retrieved or created.

    Type Parameters
    Name Description
    T

    Type of the component.

    EnsureComponent<T>(GameObject)

    Ensure that a component of type T exists on the game object. If it doesn't exist, creates it.

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

    Game object on which component should be.

    Returns
    Type Description
    T

    The component that was retrieved or created.

    Type Parameters
    Name Description
    T

    Type of the component.

    Remarks

    This extension has to remain in this class as it is required by the EnsureComponent<T>(Component) method

    EnsureComponent<T>(GameObject)

    Ensure that a component of type T exists on the game object. If it doesn't exist, creates it.

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

    Game object on which component should be.

    Returns
    Type Description
    T

    The component that was retrieved or created.

    Type Parameters
    Name Description
    T

    Type of the component.

    Remarks

    This extension has to remain in this class as it is required by the EnsureComponent<T>(Component) method

    FindAncestorComponent<T>(Component, Boolean)

    Find the first component of type T in the ancestors of the game object of the specified component.

    Declaration
    public static T FindAncestorComponent<T>(this Component component, bool includeSelf = true)
    
        where T : Component
    Parameters
    Type Name Description
    Component component

    Component for which its game object's ancestors must be considered.

    Boolean includeSelf

    Indicates whether the specified game object should be included.

    Returns
    Type Description
    T

    The component of type T. Null if it none was found.

    Type Parameters
    Name Description
    T

    Type of component to find.

    FindAncestorComponent<T>(Component, Boolean)

    Find the first component of type T in the ancestors of the game object of the specified component.

    Declaration
    public static T FindAncestorComponent<T>(this Component component, bool includeSelf = true)
    
        where T : Component
    Parameters
    Type Name Description
    Component component

    Component for which its game object's ancestors must be considered.

    Boolean includeSelf

    Indicates whether the specified game object should be included.

    Returns
    Type Description
    T

    The component of type T. Null if it none was found.

    Type Parameters
    Name Description
    T

    Type of component to find.

    In This Article
    • Methods
      • EnsureComponent(GameObject, Type)
      • EnsureComponent(GameObject, Type)
      • EnsureComponent<T>(Component)
      • EnsureComponent<T>(Component)
      • EnsureComponent<T>(GameObject)
      • EnsureComponent<T>(GameObject)
      • FindAncestorComponent<T>(Component, Boolean)
      • FindAncestorComponent<T>(Component, Boolean)
    Back to top Generated by DocFX