using UnityEngine; public static class Utils { public static GameObject FindRecursive(this GameObject go, string child) { var foundChild = go.transform.Find(child); if (foundChild != null) { return foundChild.gameObject; }else { var found = false; GameObject newChild = null; foreach (Transform newGo in go.transform) { if (newGo.childCount > 0) newChild = newGo.gameObject.FindRecursive(child); found = child == newChild?.name; if (found) break; } if (found) return newChild; else return null; } } public static Transform FindRecursive(this Transform transform, string child) { var foundChild = transform.gameObject.FindRecursive(child); return foundChild != null ? foundChild.transform : null; } }