mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
SearchUtilities.FindAll
This commit is contained in:
parent
23562015b6
commit
2543d8b94d
@ -179,5 +179,31 @@ namespace NewHorizons.Utility
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// transform.find but works for gameobjects with same name
|
||||
/// </summary>
|
||||
public static List<Transform> FindAll(this Transform @this, string path)
|
||||
{
|
||||
var names = path.Split('/');
|
||||
var currentTransforms = new List<Transform> { @this };
|
||||
foreach (var name in names)
|
||||
{
|
||||
var newTransforms = new List<Transform>();
|
||||
foreach (var currentTransform in currentTransforms)
|
||||
{
|
||||
foreach (Transform child in currentTransform)
|
||||
{
|
||||
if (child.name == name)
|
||||
{
|
||||
newTransforms.Add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
currentTransforms = newTransforms;
|
||||
}
|
||||
|
||||
return currentTransforms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user