public static bool GetComponentInChildren <T>(this GameObject obj, out T comp) where T : class { if (obj == null) { comp = null; return(false); } comp = obj.GetComponentInChildren(typeof(T)) as T; return(ObjUtil.IsObjectAlive(comp as UnityEngine.Object)); }
public static bool GetComponent(this Component obj, System.Type tp, out Component comp) { if (obj == null) { comp = null; return(false); } comp = obj.GetComponent(tp); return(ObjUtil.IsObjectAlive(comp as UnityEngine.Object)); }
public static bool GetComponent <T>(this Component obj, out T comp) where T : class { if (obj == null) { comp = null; return(false); } comp = obj.GetComponent <T>(); return(ObjUtil.IsObjectAlive(comp as UnityEngine.Object)); }
public static void GetComponents <T>(this GameObject obj, ICollection <T> lst, System.Func <Component, T> filter) where T : class { if (obj == null) { return; } using (var tmpLst = TempCollection.GetList <Component>()) { obj.GetComponents(typeof(Component), tmpLst); var e = tmpLst.GetEnumerator(); T c; while (e.MoveNext()) { c = (filter != null) ? filter(e.Current) : e.Current as T; if (ObjUtil.IsObjectAlive(c as UnityEngine.Object)) { lst.Add(c); } } } }
public static bool FindComponent <T>(this GameObject go, out T comp) where T : class { comp = FindComponent <T>(go); return(ObjUtil.IsObjectAlive(comp as UnityEngine.Object)); }
public static bool FindComponent(this GameObject go, System.Type tp, out Component comp) { comp = FindComponent(go, tp); return(ObjUtil.IsObjectAlive(comp)); }