Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
0
      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;
      }