SpookTubeEX/Util.cs

20 lines
495 B
C#
Raw Normal View History

2024-05-28 20:04:22 +10:00
using UnityEngine;
2024-06-04 19:53:14 +10:00
namespace SpookTubeEX;
2024-05-28 20:04:22 +10:00
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;
}
}