diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index 0349e1b6..b6086917 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -179,5 +179,31 @@ namespace NewHorizons.Utility } return children; } + + /// + /// transform.find but works for gameobjects with same name + /// + public static List FindAll(this Transform @this, string path) + { + var names = path.Split('/'); + var currentTransforms = new List { @this }; + foreach (var name in names) + { + var newTransforms = new List(); + foreach (var currentTransform in currentTransforms) + { + foreach (Transform child in currentTransform) + { + if (child.name == name) + { + newTransforms.Add(child); + } + } + } + currentTransforms = newTransforms; + } + + return currentTransforms; + } } }