コード例 #1
0
        public virtual void Run(params object[] param)
        {
            if (_isRunning)
            {
                CLog.LogError("GameRunner,id=" + _id + " is running,can not run again!");
                return;
            }
            _isRunning = true;
            GameCfg gameCfg = GameConfig.GetGameCfg(this._id);

            if (GO == null)
            {
                GO = new GameObject(gameCfg.name);
                GameObject.DontDestroyOnLoad(GO);
            }
            Transform uiTrans = AppManager.Instance.GameStarter.transform.FindChild(gameCfg.ui + "_Template");

            if (uiTrans != null)
            {
                GameObject ui = GameObject.Instantiate(uiTrans.gameObject);
                CTLTools.AddChildToParent(ui, GO, false);
                ui.transform.Find("UICamera").GetComponent <Camera>().depth = gameCfg.uiDepth;
                ui.SetActive(true);
                ui.name = "UI";
            }
            else
            {
                CLog.LogError("can not find UI template in GameStarter!UI:" + gameCfg.ui);
            }

            STContainer = GO.AddComponent <SingletonContainer>();
            STContainer.ResourceMgr.Init(GameConfig.IsResourceLoadMode, string.Format("Assets/{0}/Res", gameCfg.rootDir));
            STContainer.LuaClient.BindGame(gameCfg.id);
            STContainer.LuaClient.StartGame();
        }
コード例 #2
0
        public static GameObject CreateUGUIViewContainer(GameObject parent, int level)
        {
            Transform trans = parent.transform;
            Transform child = trans.FindChild(level.ToString());

            if (child == null)
            {
                GameObject go = new GameObject();
                CTLTools.AddChildToParent(go, parent, false);
                go.name = level.ToString();
                child   = go.transform;
                //子容器里面的对象排序
                int count = trans.childCount;
                _list.Clear();
                for (int i = 0; i < count; i++)
                {
                    _list.Add(trans.GetChild(i));
                }
                _list.Sort(delegate(Transform a, Transform b){
                    int aValue = int.Parse(a.name);
                    int bValue = int.Parse(b.name);
                    return(aValue - bValue);
                });
                for (int i = 0; i < _list.Count; i++)
                {
                    _list[i].SetSiblingIndex(i);
                }
            }
            return(child.gameObject);
        }