Esempio n. 1
0
        /// <summary>
        /// 重启项目(动更完成后)
        /// </summary>
        private void Relaunch()
        {
            // destroy
            Common.luaMgr.Destroy();
            Destroy(Common.looper);
            Destroy(Stage.uiCanvas.gameObject);

            // clear reference
            Stage.ClearReference();
            AudioManager.ClearReference();
            SafeAreaLayout.ClearReference();
            LocalizationText.ClearReference();
            ViewPager.ClearReference();
            TcpSocket.ClearReference();
            UdpSocket.ClearReference();
            NetHelper.ClearReference();
            DestroyEventDispatcher.ClearReference();
            PointerEventDispatcher.ClearReference();
            TriggerEventDispatcher.ClearReference();
            DragDropEventDispatcher.ClearReference();
            StageTouchEventDispatcher.ClearReference();
            AvailabilityEventDispatcher.ClearReference();

            // unload
            ResManager.UnloadAll();

            // relaunch
            StartCoroutine(Launch());
        }
Esempio n. 2
0
        /// <summary>
        /// 在指定的 gameObject 上添加 AvailabilityEventDispatcher 脚本。
        /// 当 gameObject 可用性有改变时(OnEnable() / OnDisable()),派发 AvailabilityEvent.CHANGED 事件
        /// </summary>
        /// <param name="go">Go.</param>
        /// <param name="ed">Ed.</param>
        public static void AddAvailabilityEvent(GameObject go, LuaTable ed)
        {
            AvailabilityEventDispatcher dispatcher = go.GetComponent <AvailabilityEventDispatcher>();

            if (dispatcher == null)
            {
                dispatcher = go.AddComponent <AvailabilityEventDispatcher>();
            }
            dispatcher.ed = ed;
        }