Method ConvertUnityObjectToType
ConvertUnityObjectToType<T>(Object)
Returns a component of the specified type that is associated with an object, if possible.
Declaration
public static T ConvertUnityObjectToType<T>(Object objectIn) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| Object | objectIn | The Unity Object reference to convert. |
Returns
| Type | Description |
|---|---|
| T | A component of type |
Type Parameters
| Name | Description |
|---|---|
| T | The type to convert to. |
Remarks
If the objectIn is the requested type, then this function casts it to
type T and returns it.
If objectIn is a GameObject, then this function returns
the first component of the requested type, if one exists.
If objectIn is a different type of component, this function returns
the first component of the requested type on the same GameObject, if one exists.