Beispiel #1
0
        /// <summary>
        /// 启动
        /// </summary>
        private IEnumerator Launch()
        {
            // 先进入启动场景
            if (SceneManager.GetActiveScene().name != Constants.LauncherSceneName)
            {
                SceneManager.LoadScene(Constants.LauncherSceneName);
            }
            // 等之前场景的内容清除完毕
            yield return(new WaitForEndOfFrame());

            // 首次启动
            if (!Common.Initialized)
            {
                Common.Initialized = true;
                TimeUtil.Initialize();
                Logger.Initialize();
                AudioManager.Initialize();

                // EventSystem
                GameObject eventSystem = new GameObject("EventSystem");
                eventSystem.AddComponent <EventSystem>();
                eventSystem.AddComponent <StandaloneInputModule>();
                eventSystem.transform.SetParent(transform);
            }

            ResManager.Initialize();
            Stage.Initialize();

            Common.looper = gameObject.AddComponent <Looper>();
            Common.luaMgr = gameObject.AddComponent <LuaManager>();
            Common.luaMgr.Initialize();// start lua

            Destroy(this);
        }
Beispiel #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        IEnumerator Initialize()
        {
            yield return(new WaitForEndOfFrame());            // 等之前场景等内容清除完毕

            // UICanvas
            ResManager.Initialize();
            GameObject uiCanvas = (GameObject)Instantiate(ResManager.LoadAsset("Prefabs/Core/UICanvas.prefab", "Core"), transform);

            uiCanvas.name     = "UICanvas";
            Stage.uiCanvasTra = (RectTransform)uiCanvas.transform;
            Stage.Initialize();

            // EventSystem
            GameObject eventSystem = new GameObject("EventSystem");

            eventSystem.AddComponent <EventSystem> ();
            eventSystem.AddComponent <StandaloneInputModule> ();
            eventSystem.transform.SetParent(transform);

            Common.looper = gameObject.AddComponent <Looper> ();
            Common.luaMgr = gameObject.AddComponent <LuaManager> ();

            TimeUtil.Initialize();
            Logger.Initialize();
            Common.luaMgr.Initialize();             // start lua

            Destroy(this);
        }