Example #1
0
 public static GameObject Find(string name, bool includeHidden = true)
 {
     if (Application.isLoadingLevel)
     {
         return(null);
     }
     if (!Locate.cleanGameObjects)
     {
         Locate.Build <Transform>();
     }
     name = name.Trim("/");
     if (Locate.searchCache.ContainsKey(name))
     {
         return(Locate.searchCache[name]);
     }
     GameObject[] all = includeHidden ? Locate.sceneObjects : Locate.enabledObjects;
     foreach (GameObject current in all)
     {
         if (current.IsNull())
         {
             continue;
         }
         string path = current.GetPath().Trim("/");
         if (path == name)
         {
             Locate.searchCache[name] = current;
             return(current);
         }
     }
     return(null);
 }
Example #2
0
        public static GameObject[] GetByName(string name)
        {
            if (Application.isLoadingLevel)
            {
                return(new GameObject[0]);
            }
            if (!Locate.cleanGameObjects)
            {
                Locate.Build <Transform>();
            }
            List <GameObject> matches = new List <GameObject>();

            foreach (GameObject current in Locate.enabledObjects)
            {
                if (current.IsNull())
                {
                    continue;
                }
                if (current.name == name)
                {
                    matches.Add(current);
                }
            }
            return(matches.ToArray());
        }
Example #3
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)]);
 }
Example #4
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);
 }