示例#1
0
 public static GameObject[] GetSceneObjects(bool includeEnabled = true, bool includeDisabled = true)
 {
     if (Application.isLoadingLevel)
     {
         return(new GameObject[0]);
     }
     if (!Locate.cleanGameObjects)
     {
         Locate.Build <Transform>();
     }
     if (includeEnabled && includeDisabled)
     {
         return(Locate.sceneObjects);
     }
     if (!includeEnabled)
     {
         return(Locate.disabledObjects);
     }
     return(Locate.enabledObjects);
 }
示例#2
0
 //=====================
 // Components
 //=====================
 public static Type[] GetSceneComponents <Type>(bool includeEnabled = true, bool includeDisabled = true) where Type : Component
 {
     if (Application.isLoadingLevel)
     {
         return(new Type[0]);
     }
     if (!Locate.cleanSceneComponents.Contains(typeof(Type)))
     {
         Locate.Build <Type>();
     }
     if (includeEnabled && includeDisabled)
     {
         return((Type[])Locate.sceneComponents[typeof(Type)]);
     }
     if (!includeEnabled)
     {
         return((Type[])Locate.disabledComponents[typeof(Type)]);
     }
     return((Type[])Locate.enabledComponents[typeof(Type)]);
 }
示例#3
0
 public static GameObject[] GetSiblings(this GameObject current, bool includeEnabled = true, bool includeDisabled = true, bool includeSelf = true)
 {
     if (Application.isLoadingLevel)
     {
         return(new GameObject[0]);
     }
     if (!Locate.cleanSiblings.Contains(current))
     {
         GameObject        parent = current.GetParent();
         List <GameObject> siblings;
         if (parent.IsNull())
         {
             Locate.GetSceneObjects(includeEnabled, includeDisabled);
             siblings = Locate.rootObjects.Remove(current).ToList();
         }
         else
         {
             siblings = parent.GetComponentsInChildren <Transform>(true).Select(x => x.gameObject).ToList();
             siblings.RemoveAll(x => x.GetParent() != parent);
         }
         Locate.siblings[current]         = siblings.ToArray();
         Locate.enabledSiblings[current]  = Locate.siblings[current].Where(x => !x.IsNull() && x.gameObject.activeInHierarchy).Select(x => x.gameObject).ToArray();
         Locate.disabledSiblings[current] = Locate.siblings[current].Where(x => !x.IsNull() && !x.gameObject.activeInHierarchy).Select(x => x.gameObject).ToArray();
         Locate.cleanSiblings.Add(current);
     }
     GameObject[] results = Locate.enabledSiblings[current];
     if (includeEnabled && includeDisabled)
     {
         results = Locate.siblings[current];
     }
     if (!includeEnabled)
     {
         results = Locate.disabledSiblings[current];
     }
     if (!includeSelf)
     {
         results = results.Remove(current);
     }
     return(results);
 }
示例#4
0
 public static int GetSiblingCount(this GameObject current, bool includeInactive = false)
 {
     return(Locate.GetSiblings(current, true, includeInactive).Length);
 }