diff --git a/Runtime/Extensions/TransformExtensions.cs b/Runtime/Extensions/TransformExtensions.cs index ec582e0..c336911 100644 --- a/Runtime/Extensions/TransformExtensions.cs +++ b/Runtime/Extensions/TransformExtensions.cs @@ -464,5 +464,24 @@ public static void ScaleAround(this Transform target, Vector3 pivot, Vector3 new target.localScale = newScale; target.localPosition = finalPosition; } + + /// + /// Find a child transform with the specified name. + /// + /// The parent to start search from. + /// The name of the transform to find. + /// that matches or null. + public static Transform FindChildRecursive(this Transform parent, string name) + { + for (int i = 0; i < parent.childCount; i++) + { + var child = parent.GetChild(i); + if (child.name.Contains(name)) { return child; } + var result = child.FindChildRecursive(name); + if (result != null) { return result; } + } + + return null; + } } } diff --git a/package.json b/package.json index f75f480..05e4aca 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Utilities.Extensions", "description": "Common extensions for Unity types (UPM)", "keywords": [], - "version": "1.1.16", + "version": "1.1.17", "unity": "2021.3", "documentationUrl": "https://github.com/RageAgainstThePixel/com.utilities.extensions#documentation", "changelogUrl": "https://github.com/RageAgainstThePixel/com.utilities.extensions/releases",