Class TransformExtensions
Extension methods for Unity Transforms, including bone hierarchy and child GameObject search utilities.
public static class TransformExtensions
- Inheritance
-
TransformExtensions
- Inherited Members
Methods
FindAllChildGameObjects(Transform, string)
Finds all child GameObjects in the hierarchy, optionally filtering by name prefix.
public static List<GameObject> FindAllChildGameObjects(this Transform root, string prefix = null)
Parameters
rootTransformThe root transform to start searching from.
prefixstringOptional name prefix to filter child GameObjects.
Returns
- List<GameObject>
List of found child GameObjects.
GetBones(Transform)
Recursively collects all bones in the hierarchy starting from the root bone. All child Transforms are included regardless of additional components. Previously restricted to Transforms with exactly one component — this caused equipment binding failures when artists added scripts, colliders, or other components to bone GameObjects.
public static Dictionary<string, Transform> GetBones(this Transform transform)
Parameters
transformTransformThe transform to search for bones.
Returns
- Dictionary<string, Transform>
Dictionary mapping bone names to their Transform objects.
GetRootBone(Transform)
Searches the GameObject's hierarchy and looks for a root bone. Returns the first child Transform (typically the skeleton root). Returns null if no children exist.
public static Transform GetRootBone(this Transform gameObject)
Parameters
gameObjectTransformThe transform to search for a root bone.
Returns
- Transform
The root bone Transform, or null if not found.