GameObjectExt ClassGameObject extensions.
Inheritance Hierarchy
System.Object
UltimateXR.Extensions.Unity.GameObjectExt
Namespace: UltimateXR.Extensions.Unity
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0
Syntax
C#
public static class GameObjectExt
The GameObjectExt type exposes the following members.
Methods
Name | Description | |
---|---|---|
CheckSetActive | Activates/deactivates the object if it isn’t active already. | |
CreateGameObjectAndParentSameTransform | Creates a new GameObject in the exact same position as the given one and parents it. | |
GetBounds | Calculates the GameObjectBounds. The bounds are the Renderer’s bounds if there is one in the GameObject. Otherwise it will encapsulate all renderers found in the children. If forceRecurseIntoChildren is true, it will also encapsulate all renderers found in the children no matter if the GameObject has a Renderer component or not. | |
GetGeometricCenter | Computes the geometric center of the given GameObject based on all the MeshRenderers in the hierarchy. | |
GetLocalBounds | Calculates the GameObjectBounds in local space. The bounds are the Renderer’s bounds if there is one in the GameObject. Otherwise it will encapsulate all renderers found in the children. If forceRecurseIntoChildren is true, it will also encapsulate all renderers found in the children no matter if the GameObject has a Renderer component or not. | |
GetOrAddComponent<T> | Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. | |
GetPathUnderScene | Gets the path in the scene of the given GameObject. | |
GetTopmostCanvas | Gets the topmost UxrCanvas upwards in the hierarchy if it exists. | |
GetUniqueScenePath | Gets a unique path in the scene for the given GameObject. It will include sibling indices to make it unique. | |
IsDynamic | Checks whether the given GameObject is dynamic. Since isStatic doesn’t work at runtime due to the static flags being editor-only, a workaround is required to try to find out if an object is dynamic or not. | |
IsInLayerMask | Checks whether the given GameObject’s layer is present in a layer mask. | |
IsPrefab | Checks if the given GameObject is a prefab. | |
SafeGetComponentInParent<T> | Gets the Component of a given type in the GameObject or any of its parents. It also works on prefabs, where regular GetComponentInParent(Type, Boolean) will not work: https://issuetracker.unity3d.com/issues/getcomponentinparent-is-returning-null-when-the-gameobject-is-a-prefab | |
SetLayerRecursively | Sets the layer of a GameObject and all its children. |