ComponentExtensions Class

Definition

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

C++
public ref class ComponentExtensions abstract sealed
Inheritance
ComponentExtensions

Methods

EnsureComponent(GameObject, Type)

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

EnsureComponent<T>(Component)

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

EnsureComponent<T>(GameObject)

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

FindAncestorComponent<T>(Component, Boolean)

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

Applies to

Produit Versions
MRTK2 Unity 2018 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.6.0, 2.7.0
MRTK2 Unity 2019 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.6.0, 2.7.0, 2.8.0
MRTK2 Unity 2020 2.5.2, 2.5.3, 2.5.4, 2.6.0, 2.7.0, 2.8.0