make findchild take path and also be an extension method

This commit is contained in:
JohnCorby 2022-06-30 19:49:43 -07:00
parent d5b9376fc3
commit bb3b111358
2 changed files with 2 additions and 10 deletions

View File

@ -265,7 +265,7 @@ namespace NewHorizons.Builder.Props
// setup for visually supporting async texture loading
mindSlideProjector.enabled = false;
var visionBeamEffect = SearchUtilities.FindChild(standingTorch, "VisionBeam");
var visionBeamEffect = standingTorch.FindChild("VisionBeam");
visionBeamEffect.SetActive(false);
//

View File

@ -118,15 +118,7 @@ namespace NewHorizons.Utility
}
*/
public static GameObject FindChild(GameObject g, string childName)
{
foreach(Transform child in g.transform)
{
if (child.gameObject.name == childName) return child.gameObject;
}
return null;
}
public static GameObject FindChild(this GameObject g, string path) => g?.transform?.Find(path)?.gameObject;
public static GameObject Find(string path, bool warn = true)
{