PixelCrushers.GameObjectUtility Class Reference

Utility functions for working with GameObjects. More...

Static Public Member Functions

static T FindFirstObjectByType< T > ()
 
static UnityEngine.Object FindFirstObjectByType (System.Type type)
 
static T[] FindObjectsByType< T > ()
 
static UnityEngine.Object[] FindObjectsByType (System.Type type)
 
static bool IsPrefab (GameObject go)
 Determines if a GameObject reference is a non-instantiated prefab or a scene object.
 
static bool DoesGameObjectPathMatch (Transform t, string requiredPath)
 Returns true if the end of a transform's hierarchy path matches a specified path.
 
static string GetHierarchyPath (Transform t)
 Returns the full hierarchy path.
 
static GameObject GameObjectHardFind (string goName, bool checkAllScenes=true)
 Finds an in-scene GameObject by name even if it's inactive.
 
static GameObject GameObjectHardFind (string goName, string tag, bool checkAllScenes=true)
 Finds an in-scene GameObject by name and tag even if it's inactive.
 
static T[] FindObjectsOfTypeAlsoInactive< T > (bool checkAllScenes=true)
 Finds all objects of a type, including on inactive GameObjects.
 
static T GetComponentAnywhere< T > (GameObject gameObject)
 Like GetComponentInChildren(), but also searches parents.
 
static float GetGameObjectHeight (GameObject gameObject)
 Gets the height of the game object based on its collider.
 

Detailed Description

Utility functions for working with GameObjects.

Member Function Documentation

◆ DoesGameObjectPathMatch()

static bool PixelCrushers.GameObjectUtility.DoesGameObjectPathMatch ( Transform  t,
string  requiredPath 
)
inlinestatic

Returns true if the end of a transform's hierarchy path matches a specified path.

For example, if the transform's hierarchy is A/B/C/D, it will match a requiredPath of C/D.

◆ FindFirstObjectByType()

static UnityEngine.Object PixelCrushers.GameObjectUtility.FindFirstObjectByType ( System::Type  type)
inlinestatic

◆ FindFirstObjectByType< T >()

Type Constraints
T :UnityEngine.Object 

◆ FindObjectsByType()

static UnityEngine.Object[] PixelCrushers.GameObjectUtility.FindObjectsByType ( System::Type  type)
inlinestatic

◆ FindObjectsByType< T >()

static T[] PixelCrushers.GameObjectUtility.FindObjectsByType< T > ( )
inlinestatic
Type Constraints
T :UnityEngine.Object 

◆ FindObjectsOfTypeAlsoInactive< T >()

static T[] PixelCrushers.GameObjectUtility.FindObjectsOfTypeAlsoInactive< T > ( bool  checkAllScenes = true)
inlinestatic

Finds all objects of a type, including on inactive GameObjects.

Parameters
checkAllScenesIf true, check all open scenes; otherwise only check active scene.
Type Constraints
T :Component 

◆ GameObjectHardFind() [1/2]

static GameObject PixelCrushers.GameObjectUtility.GameObjectHardFind ( string  goName,
bool  checkAllScenes = true 
)
inlinestatic

Finds an in-scene GameObject by name even if it's inactive.

Parameters
goNameName of the GameObject.
checkAllScenesIf true, check all open scenes; otherwise only check active scene.
Returns
The GameObject.

◆ GameObjectHardFind() [2/2]

static GameObject PixelCrushers.GameObjectUtility.GameObjectHardFind ( string  goName,
string  tag,
bool  checkAllScenes = true 
)
inlinestatic

Finds an in-scene GameObject by name and tag even if it's inactive.

Parameters
goNameGameObject name to search for.
tagTag to search for.
checkAllScenesIf true, check all open scenes; otherwise only check active scene.
Returns

◆ GetComponentAnywhere< T >()

static T PixelCrushers.GameObjectUtility.GetComponentAnywhere< T > ( GameObject  gameObject)
inlinestatic

Like GetComponentInChildren(), but also searches parents.

Returns
The component, or null if not found.
Parameters
gameObjectGame object to search.
Template Parameters
TThe component type.
Type Constraints
T :Component 

◆ GetGameObjectHeight()

static float PixelCrushers.GameObjectUtility.GetGameObjectHeight ( GameObject  gameObject)
inlinestatic

Gets the height of the game object based on its collider.

This only works if the game object has a CharacterController, CapsuleCollider, BoxCollider, or SphereCollider.

Returns
The game object height if it has a recognized type of collider; otherwise 0.
Parameters
gameObjectGame object.

◆ GetHierarchyPath()

static string PixelCrushers.GameObjectUtility.GetHierarchyPath ( Transform  t)
inlinestatic

Returns the full hierarchy path.

Parameters
current
Returns

◆ IsPrefab()

static bool PixelCrushers.GameObjectUtility.IsPrefab ( GameObject  go)
inlinestatic

Determines if a GameObject reference is a non-instantiated prefab or a scene object.

If go is null, active in the scene, or its parent is active in the scene, it's considered a scene object. Otherwise this method searches all scene objects for matches. If it doesn't find any matches, this is a prefab.

Returns
true if a prefab; otherwise, false.
Parameters
goGameObject.

The documentation for this class was generated from the following file: