GameObjectExtensions¶
Namespace:
SideXP.Core
Extension functions for GameObject instances.
Methods¶
GetChildren(GameObject, bool)¶
Gets the children from a given Game Object (excluding itself).
Parameters
gameObject: The Game Object from which you want to get the children (excluding itself).recursive: By default, this function processes only direct children. If enabled, gets the children recursively in the hierarchy.
Returns
Returns the found children.
IsPrefab(GameObject)¶
Checks if a GameObject is a prefab at runtime.
Parameters
gameObject: TheGameObjectto check.
Returns
Returns true if the given object is a prefab.
GetBounds(GameObject, bool, bool)¶
public static Bounds GetBounds(GameObject gameObject, bool preferCollider = false, bool includeChildren = true)
Gets the bounds of an object, using its renderer or collider.
Parameters
gameObject: The object to get the bounds.preferCollider: If enabled, try to get the object bounds from the collider first, instead of the renderer first.includeChildren: If enabled and the given object doesn't have a component that may contain bounds, this function will search for that component in children.
Returns
Returns the object bounds.
GetBounds(GameObject, Bounds, bool, bool)¶
public static bool GetBounds(GameObject gameObject, out Bounds bounds, bool preferCollider = false, bool includeChildren = true)
Gets the bounds of an object, using its renderer or collider.
Parameters
gameObject: The object to get the bounds.bounds: Outputs the object bounds.preferCollider: If enabled, try to get the object bounds from the collider first, instead of the renderer first.includeChildren: If enabled and the given object doesn't have a component that may contain bounds, this function will search for that component in children.
Returns
Returns true if the object bounds have been found.
TryGetComponentInParent(GameObject, Type, Component, bool)¶
public static bool TryGetComponentInParent(GameObject component, Type componentType, out Component output, bool includeInactive)
Parameters
component: The Game Object from which to get the target one.componentTypeoutput: Outputs the found component of the given type.
Returns
Returns true if a component of the expected type has been found on the given Game Object, or its parent.
TryGetComponentInParent(GameObject, Type, Component)¶
public static bool TryGetComponentInParent(GameObject component, Type componentType, out Component output)
Parameters
component: The Game Object from which to get the target one.componentTypeoutput: Outputs the found component of the given type.
Returns
Returns true if a component of the expected type has been found on the given Game Object, or its parent.
TryGetComponentInParent<T>(GameObject, T, bool)¶
public static bool TryGetComponentInParent<T>(GameObject component, out T output, bool includeInactive)
Inherited documentation.
TryGetComponentInParent<T>(GameObject, T)¶
Inherited documentation.
TryGetComponentInChildren(GameObject, Type, Component, bool)¶
public static bool TryGetComponentInChildren(GameObject component, Type componentType, out Component output, bool includeInactive)
Parameters
component: The Game Object from which to get the target one.componentTypeoutput: Outputs the found component of the given type.
Returns
Returns true if a component of the expected type has been found on the given Game Object, or its children.
TryGetComponentInChildren(GameObject, Type, Component)¶
public static bool TryGetComponentInChildren(GameObject component, Type componentType, out Component output)
Parameters
component: The Game Object from which to get the target one.componentTypeoutput: Outputs the found component of the given type.
Returns
Returns true if a component of the expected type has been found on the given Game Object, or its children.
TryGetComponentInChildren<T>(GameObject, T, bool)¶
public static bool TryGetComponentInChildren<T>(GameObject component, out T output, bool includeInactive)
Inherited documentation.
TryGetComponentInChildren<T>(GameObject, T)¶
Inherited documentation.