Example #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());
        }
        /// <summary>
        /// 主动释放当前穿透击中的目标,触发 target.OnPointerUp()
        /// </summary>
        public void ReleaseTarget()
        {
            if (m_target == null)
            {
                return;
            }

            PointerEventData eventData = new PointerEventData(EventSystem.current)
            {
                position = StageTouchEventDispatcher.GetPosition()
            };

            ExecuteEvents.Execute(m_target, eventData, ExecuteEvents.pointerUpHandler);
            m_target = null;
        }
Example #3
0
        void Update()
        {
            TimeUtil.Update();
            Timer.Update();
            UdpSocket.Update();


            // 执行需要在主线程运行的 Action
            lock (LOCK_OBJECT) {
                if (m_threadActions.Count > 0)
                {
                    m_tempActions.AddRange(m_threadActions);
                    m_threadActions.Clear();
                }
            }
            if (m_tempActions.Count > 0)
            {
                foreach (Action action in m_tempActions)
                {
                    try {
                        action();
                    } catch (Exception e) {
                        Logger.LogException(e);
                    }
                }
                m_tempActions.Clear();
            }


            // 执行网络相关回调
            lock (LOCK_OBJECT) {
                if (m_netActions.Count > 0)
                {
                    m_tempActions.AddRange(m_netActions);
                    m_netActions.Clear();
                }
            }
            if (m_tempActions.Count > 0)
            {
                foreach (Action action in m_tempActions)
                {
                    try {
                        action();
                    } catch (Exception e) {
                        Logger.LogException(e);
                    }
                }
                m_tempActions.Clear();
            }


            // 屏幕尺寸有改变
            if (Screen.width != m_screenSize.x || Screen.height != m_screenSize.y)
            {
                m_screenSize.Set(Screen.width, Screen.height);
                List <Action> removes = new List <Action> ();
                foreach (Action handler in resizeHandler)
                {
                    try {
                        handler();
                    } catch (Exception e) {
                        removes.Add(handler);
                        Logger.LogException(e);
                    }
                }
                // 移除执行时报错的 action
                foreach (Action handler in removes)
                {
                    resizeHandler.Remove(handler);
                }

                // lua Resize
                m_luaLoopHandler.BeginPCall();
                m_luaLoopHandler.Push(EVENT_RESIZE);
                m_luaLoopHandler.Push(TimeUtil.timeSec);
                m_luaLoopHandler.PCall();
                m_luaLoopHandler.EndPCall();
            }

            StageTouchEventDispatcher.Update();

            // lua Update
            m_luaLoopHandler.BeginPCall();
            m_luaLoopHandler.Push(EVENT_UPDATE);
            m_luaLoopHandler.Push(TimeUtil.timeSec);
            m_luaLoopHandler.PCall();
            m_luaLoopHandler.EndPCall();
        }
Example #4
0
        void Update()
        {
#if UNITY_EDITOR
            // Unity2018 FrameDebugger 窗口会更新内容,导致无法查看数据
            if (UnityEditor.EditorApplication.isPaused)
            {
                return;
            }
#endif

            TimeUtil.Update();
            Timer.Update();
            UdpSocket.Update();
            NetHelper.Update();


            lock (LOCK_OBJECT)
            {
                // 需要在主线程运行的 Action
                if (m_threadActions.Count > 0)
                {
                    m_tempActions.AddRange(m_threadActions);
                    m_threadActions.Clear();
                }

                // 网络相关回调
                if (m_netActions.Count > 0)
                {
                    m_tempActions.AddRange(m_netActions);
                    m_netActions.Clear();
                }
            }

            if (m_tempActions.Count > 0)
            {
                foreach (Action action in m_tempActions)
                {
                    try
                    {
                        action();
                    }
                    catch (Exception e)
                    {
                        Logger.LogException(e);
                    }
                }
                m_tempActions.Clear();
            }


            // 设备方向有变化
            if (DeviceHelper.Update())
            {
                ScreenOrientationHandler.Call();
            }

            // 屏幕尺寸有改变
            if (Screen.width != m_screenSize.x || Screen.height != m_screenSize.y)
            {
                m_screenSize.Set(Screen.width, Screen.height);
                ResizeHandler.Call();
                DispatchLuaEvent(EVENT_RESIZE);
            }

            // 全局屏幕 Touch 相关
            StageTouchEventDispatcher.Update();

            // lua Update
            DispatchLuaEvent(EVENT_UPDATE);
        }