using UnityEngine; namespace OHM.UnityToolkit { public static class ComponentsUtils { public static bool GetRequiredComponentInChildren(Component parent, ref ComponentToFind componentToFind) { if (!IsNull(componentToFind)) { return true; } componentToFind = parent.GetComponentInChildren(true); return !IsNull(componentToFind); } public static bool GetRequiredComponentInParent(Component parent, ref ComponentToFind componentToFind) { if (!IsNull(componentToFind)) { return true; } componentToFind = parent.GetComponentInParent(); return !IsNull(componentToFind); } public static bool GetRequiredComponent(Component parent, ref ComponentToFind componentToFind) { if (!IsNull(componentToFind)) { return true; } componentToFind = parent.GetComponent(); return !IsNull(componentToFind); } public static ComponentToFind GetRequiredComponent(Component parent) { return parent.GetComponent(); } private static bool IsNull(T value) { if (value == null) { return true; } return value is UnityEngine.Object obj && obj == null; } } }