SpookTubeEX/Util.cs

20 lines
495 B
C#

using UnityEngine;
namespace SpookTubeEX;
static class Util
{
// https://discussions.unity.com/t/how-to-find-an-inactive-game-object/129521
public static GameObject FindObject(this GameObject parent, string name)
{
Transform[] trs = parent.GetComponentsInChildren<Transform>(true);
foreach (Transform t in trs)
{
if (t.name.StartsWith(name))
{
return t.gameObject;
}
}
return null;
}
}