require("Base/BasePanel") LoadingPanel = Inherit(BasePanel) local this = LoadingPanel --初始化组件(用于子类重写) function LoadingPanel:InitComponent() Log("LoadingPanel:InitComponent") this.Slider = Util.GetGameObject(self.gameObject, "Slider"):GetComponent("Slider") this.Tip = Util.GetGameObject(self.gameObject, "Slider/Image/LoadingText"):GetComponent("Text") this.SliderText = Util.GetGameObject(self.gameObject, "Slider/Fill Area/Fill/Image/Text"):GetComponent("Text") screenAdapte(Util.GetGameObject(self.gameObject, "bg1")) screenAdapte(Util.GetGameObject(self.gameObject, "bg2")) end local callList = {} local curIndex = 0 local lerp = 0 local maxIndex = 0 local function update() if this.Slider then lerp = math.clamp(lerp + Time.fixedDeltaTime * 15,0,1) local curValue = this.Slider.value * (1-lerp) + curIndex * lerp this.Slider.value = curValue local curTextValue = math.floor(((this.Slider.value * (1-lerp) + curIndex * lerp)/32)*100) curTextValue = curTextValue > 100 and 100 or curTextValue this.SliderText.text = curTextValue .."%" end end function LoadingPanel.AddStep(func) table.insert(callList, func) maxIndex = maxIndex + 1 end function LoadingPanel.OnStep() lerp = 0 curIndex = curIndex + 1 if callList[curIndex] then callList[curIndex]() end end -- 登录时有接口报错时执行,防止登录报错卡死导致进不去游戏的问题 function LoadingPanel.ErrorStep(msg) -- if curIndex >= maxIndex then return end LogError(Language[11344]..curIndex..Language[11345]..msg.errCode .. "|"..msg.errMsg) -- 强制进入下一步 LoadingPanel.OnStep() end function LoadingPanel.Start() if #callList <= 1 then return end UIManager.OpenPanel(UIName.LoadingPanel) UpdateBeat:Add(update) lerp = 0 curIndex = 0 this.Slider.maxValue = #callList - 1 this.Slider.value = curIndex --"你知道嘛:充值会让你变得更强!" --Language[11346] this.Tip.text = "" LoadingPanel.OnStep() end function LoadingPanel.End() UpdateBeat:Remove(update) this:ClosePanel() callList = {} end return LoadingPanel