Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/BitStrap/GameObjectExtensions.cs
2026-02-21 16:45:37 +08:00

28 lines
526 B
C#

using UnityEngine;
namespace BitStrap
{
public static class GameObjectExtensions
{
public static T GetComponentInParent<T>(this GameObject self, bool includeInactive) where T : Component
{
if (includeInactive)
{
T val = (T)null;
Transform transform = self.transform;
while (transform != null)
{
val = transform.GetComponent<T>();
if (val != null)
{
break;
}
transform = transform.parent;
}
return val;
}
return self.GetComponentInParent<T>();
}
}
}