Class MonoBehaviourExtensions
UnityEngine.MonoBehaviour Based Extension Methods
Inheritance
Namespace: GDX
Syntax
[VisualScriptingCompatible((short)2)]
public static class MonoBehaviourExtensions
Methods
| Improve this Doc View SourceGetFirstComponentInChildrenComplex<T>(MonoBehaviour, Boolean, Boolean, Int32)
A slightly more complex version of UnityEngine.Component.GetComponentInChildren<T>(System.Boolean) which allows for different hinted search options.
Declaration
public static T GetFirstComponentInChildrenComplex<T>(this MonoBehaviour targetMonoBehaviour, bool includeInactive = false, bool lookInChildrenFirst = false, int maxLevelsOfRecursion = -1)
where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.MonoBehaviour | targetMonoBehaviour | The target UnityEngine.MonoBehaviour to use as the base for the search. |
| System.Boolean | includeInactive | Include inactive child UnityEngine.GameObjects when looking for the UnityEngine.Component. |
| System.Boolean | lookInChildrenFirst | Should children UnityEngine.GameObject be searched before the
|
| System.Int32 | maxLevelsOfRecursion | The maximum levels of recursion when looking for a UnityEngine.Component, -1 for infinite recursion. |
Returns
| Type | Description |
|---|---|
| T | The first found UnityEngine.Component. |
Type Parameters
| Name | Description |
|---|---|
| T | The target UnityEngine.Component type that is being looked for. |
Remarks
If the maxLevelsOfRecursion is set to 1; this will search the
targetMonoBehaviour and its immediate children only.
The internal UnityEngine.Component.GetComponentInChildren<T>(System.Boolean) has optimizations internally in engine code which make it faster in different scenarios.
Exceptions
| Type | Condition |
|---|---|
| UnsupportedRuntimeException | Not supported on DOTS Runtime. |