Class UnityHierarchyUtils
Helpers for navigating and querying the Unity scene hierarchy
Inheritance
UnityHierarchyUtils
Assembly: Serenity.UnityGlobal.Infrastructure.dll
Syntax
public static class UnityHierarchyUtils
Methods
FindAllInSceneWithTag(string)
Returns every GameObject tagged tag under the active scene's roots (inactive included).
Declaration
public static List<GameObject> FindAllInSceneWithTag(string tag)
Parameters
| Type |
Name |
Description |
| string |
tag |
|
Returns
| Type |
Description |
| List<GameObject> |
|
FindAllInSceneWithTag(Scene, string)
Returns every GameObject tagged tag under the given scene's roots (inactive included).
Declaration
public static List<GameObject> FindAllInSceneWithTag(Scene scene, string tag)
Parameters
| Type |
Name |
Description |
| Scene |
scene |
|
| string |
tag |
|
Returns
| Type |
Description |
| List<GameObject> |
|
FindAllInScene<T>()
Returns every component of type T under the active scene's roots (inactive included).
Declaration
public static T[] FindAllInScene<T>() where T : Component
Returns
Type Parameters
FindAllInScene<T>(Scene)
Returns every component of type T under the given scene's roots (inactive included).
Declaration
public static T[] FindAllInScene<T>(Scene scene) where T : Component
Parameters
| Type |
Name |
Description |
| Scene |
scene |
|
Returns
Type Parameters
FindChildrenWithTag(GameObject, string)
Declaration
public static GameObject FindChildrenWithTag(GameObject gO, string tag)
Parameters
| Type |
Name |
Description |
| GameObject |
gO |
|
| string |
tag |
|
Returns
| Type |
Description |
| GameObject |
|
FindChildrensWithTag(GameObject, string)
Declaration
public static List<GameObject> FindChildrensWithTag(GameObject gO, string tag)
Parameters
| Type |
Name |
Description |
| GameObject |
gO |
|
| string |
tag |
|
Returns
| Type |
Description |
| List<GameObject> |
|
FindComponent<T>()
Declaration
public static T FindComponent<T>() where T : MonoBehaviour
Returns
Type Parameters
FindComponents<T>()
Declaration
public static T[] FindComponents<T>() where T : MonoBehaviour
Returns
Type Parameters
FindInSceneWithTag(string)
Finds the first GameObject tagged tag anywhere under the active scene's roots
(inactive included), or null when none matches.
Declaration
public static GameObject FindInSceneWithTag(string tag)
Parameters
| Type |
Name |
Description |
| string |
tag |
|
Returns
| Type |
Description |
| GameObject |
|
FindInSceneWithTag(Scene, string)
Finds the first GameObject tagged tag anywhere under the given scene's roots
(inactive included), or null when none matches.
Declaration
public static GameObject FindInSceneWithTag(Scene scene, string tag)
Parameters
| Type |
Name |
Description |
| Scene |
scene |
|
| string |
tag |
|
Returns
| Type |
Description |
| GameObject |
|
FindInScene<T>()
Finds the first component of type T under the active scene's roots
(inactive included), or null when none exists.
Declaration
public static T FindInScene<T>() where T : Component
Returns
Type Parameters
FindInScene<T>(Scene)
Finds the first component of type T under the given scene's roots
(inactive included), or null when none exists.
Declaration
public static T FindInScene<T>(Scene scene) where T : Component
Parameters
| Type |
Name |
Description |
| Scene |
scene |
|
Returns
Type Parameters
FindUIChildrenWithTag(GameObject, string)
Declaration
public static GameObject FindUIChildrenWithTag(GameObject gO, string tag)
Parameters
| Type |
Name |
Description |
| GameObject |
gO |
|
| string |
tag |
|
Returns
| Type |
Description |
| GameObject |
|
FindUIChildrensWithTag(GameObject, string)
Declaration
public static List<GameObject> FindUIChildrensWithTag(GameObject gO, string tag)
Parameters
| Type |
Name |
Description |
| GameObject |
gO |
|
| string |
tag |
|
Returns
| Type |
Description |
| List<GameObject> |
|
Declaration
public static RectTransform[] GetAllRectTransformsInHierarchy(GameObject root, bool includeRoot = true)
Parameters
| Type |
Name |
Description |
| GameObject |
root |
|
| bool |
includeRoot |
|
Returns
| Type |
Description |
| RectTransform[] |
|
GetGameObjectPath(GameObject)
Declaration
public static string GetGameObjectPath(GameObject obj)
Parameters
| Type |
Name |
Description |
| GameObject |
obj |
|
Returns
Declaration
public static List<GameObject> GetInmediateChildren(GameObject obj)
Parameters
| Type |
Name |
Description |
| GameObject |
obj |
|
Returns
| Type |
Description |
| List<GameObject> |
|
GetSceneRoots()
Returns the root GameObjects of the active scene. A Unity scene has several roots, so this
always returns an array; it is the starting point for the scene-scoped tag/component searches.
Declaration
public static GameObject[] GetSceneRoots()
Returns
| Type |
Description |
| GameObject[] |
|
GetSceneRoots(Scene)
Returns the root GameObjects of the given scene, or an empty array when it is not loaded.
Declaration
public static GameObject[] GetSceneRoots(Scene scene)
Parameters
| Type |
Name |
Description |
| Scene |
scene |
|
Returns
| Type |
Description |
| GameObject[] |
|
Declaration
public static bool HasParentLayoutGroup(Transform t)
Parameters
| Type |
Name |
Description |
| Transform |
t |
|
Returns
TryFindFirstImplementer<TInterface>(out TInterface)
Declaration
public static bool TryFindFirstImplementer<TInterface>(out TInterface instance)
Parameters
| Type |
Name |
Description |
| TInterface |
instance |
|
Returns
Type Parameters
| Name |
Description |
| TInterface |
|