示例#1
0
 public static void AddGameObjectDictionaryByFolder(string folderPath, GameObjectDictionary map)
 {
     FileInfo[] files = FileUtil.GetFilesByPath(folderPath);
     foreach (FileInfo item in files)
     {
         Object obj = AssetDatabase.LoadMainAssetAtPath(folderPath + item.Name);
         if (obj as GameObject != null)
         {
             map.Add(obj.name + "", obj as GameObject);
         }
     }
 }
示例#2
0
 /// <summary>
 /// 根据名字获取
 /// </summary>
 /// <param name="name"></param>
 /// <param name="map"></param>
 /// <returns></returns>
 public virtual GameObject GetGameObjectByName(string name, GameObjectDictionary map)
 {
     if (name == null)
     {
         return(null);
     }
     if (map.TryGetValue(name, out GameObject obj))
     {
         return(obj);
     }
     else
     {
         return(null);
     }
 }
      virtual protected void OnEnable()
      {
          if (_viewPrefabs == null)
          {
              _viewPrefabs = new GameObjectDictionary();
          }

          _viewPrefabs.Clear();

          if (_viewStack == null)
          {
              _viewStack = new List <IGameView>(VIEW_STACK_DEFAULT_START_SIZE);
          }

          _viewStack.Clear();
          _InitializeViewCache();

          if (_activeViewStackGameObject != null)
          {
              while (_activeViewStackGameObject.transform.childCount > 0)
              { //Disable the children of the view stack object and move them under the cache game object
                  Transform currentChild = _activeViewStackGameObject.transform.GetChild(0);

                  if (currentChild.gameObject.activeSelf)
                  {
                      currentChild.gameObject.SetActive(false);
                  }

                  currentChild.SetParent(_cacheGameObject.transform, false);
                  //add it to the cache dictionary
                  _viewCache.Add(currentChild.gameObject.GetComponent <IGameView>());
              }
          }

          _InitializeTransitionsDictionary();
          _initialized = true;
      }