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