local UIDebugView = UIViewClass() local FpsUpdateInterval = 1 local timeSinceFpsUpdate = 0 local DelayUpdateInterval = 1 local timeSinceDelayUpdate = 0 local clickStartTime = 0; local clickCount = 0; function UIDebugView:OnOpened(context) self.CheatLabel.text = "Cheat" self.showAllView = true self:RefreshLODLevel(CTL.Setting.GetLodLevel()) self:StartRepeatFunc(self.OnUpdateFun, 0) if UNITY_EDITOR or UNITY_STANDALONE then self:StartRepeatFunc(self.InputHandleForEditorOrPC,0) end UIUtils.SetActive(self.BottomLeft.gameObject, not GameAppInfo.IsMarketPackage()) self:RegistSystemEvent(EventID.UI_DebugViewShowData, self.ShowDebugViewData) self:RegistSystemEvent(EventID.Setting_SwitchLODLevel, self.RefreshLODLevel) end function UIDebugView:ShowDebugViewData(isEnter) UIUtils.SetActive(self.BottomLeft.gameObject, not self.BottomLeft.gameObject.activeSelf) end function UIDebugView:OnUpdateFun(deltaTime, timeSinceUpdate) --每2秒将clickcout清零 if clickCount > 0 then if clickStartTime <= 0 then clickStartTime = timeSinceUpdate; end if timeSinceUpdate - clickStartTime > 2 then clickCount = 0; clickStartTime = 0; end end if timeSinceUpdate - timeSinceFpsUpdate > FpsUpdateInterval then timeSinceFpsUpdate = timeSinceUpdate self.fpsLabel.text = SettingAPI.Fps end if timeSinceUpdate - timeSinceDelayUpdate > DelayUpdateInterval then timeSinceDelayUpdate = timeSinceUpdate local delayMS = BattleExt.GetNetDelayTime() self.lab_delay.text = string.format("%s ms", delayMS) end end function UIDebugView:InputHandleForEditorOrPC() if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F4) then -- 隐藏或回复界面 self.showAllView = not self.showAllView if self.showAllView then MDL.Cheat.Send("setOnlyShowDamageUI 0"); else MDL.Cheat.Send("setOnlyShowDamageUI 1"); end end if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F2) then CTL.Cheat.OpenUILuaConsole(); end if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F3) then CTL.Cheat.HandleReplayUI(); end if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.P) then CTL.Cheat.StopGame(); end if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.RightArrow) then CTL.Cheat.SwitchReplayPlayer(); end if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.LeftArrow) then CTL.Cheat.SwitchReplayPlayer(true); end if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F7) then MDL.Cheat.Send("changeEntitySpeed 0.5"); end if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F8) then MDL.Cheat.Send("changeEntitySpeed -0.5"); end end function UIDebugView:ClickLod() local lodLevel = CTL.Setting.GetLodLevel() lodLevel = lodLevel >= 2 and 0 or (lodLevel + 1) CTL.Setting.ForceSetQuality(lodLevel,MDL.Setting.SwitchLodType.Manual) end function UIDebugView:OnButtonClicked(comp) if comp == self.btn_lod then self:ClickLod() elseif comp == self.btn_cheat then CTL.Cheat.OpenUILuaConsole() elseif comp == self.btn_BackGround then clickCount = clickCount + 1; if clickCount > 3 then CTL.Cheat.OpenUILuaConsole() clickCount = 0; clickStartTime = 0; end end end function UIDebugView:RefreshLODLevel(lodLevel) self.LabelSwitch.text = string.format("LOD:%s", lodLevel); end return UIDebugView