loading 图
parent
c6aaeb91f8
commit
a998282548
|
|
@ -506,7 +506,7 @@ RectTransform:
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: -12, y: -8}
|
m_SizeDelta: {x: -12, y: -8}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
|
@ -792,7 +792,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!224 &3739793586502117409
|
--- !u!224 &3739793586502117409
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -2,52 +2,54 @@
|
||||||
LoadingPanel = Inherit(BasePanel)
|
LoadingPanel = Inherit(BasePanel)
|
||||||
local this = LoadingPanel
|
local this = LoadingPanel
|
||||||
local tipsConfig = ConfigManager.GetConfig(ConfigName.Tips)
|
local tipsConfig = ConfigManager.GetConfig(ConfigName.Tips)
|
||||||
local loadingConfig=ConfigManager.GetConfig(ConfigName.Loading)
|
local loadingConfig = ConfigManager.GetConfig(ConfigName.Loading)
|
||||||
--初始化组件(用于子类重写)
|
--初始化组件(用于子类重写)
|
||||||
local spineName=nil
|
local spineName = nil
|
||||||
local spineObj=nil
|
local spineObj = nil
|
||||||
local configLen=0
|
local configLen = 0
|
||||||
function LoadingPanel:InitComponent()
|
function LoadingPanel:InitComponent()
|
||||||
--
|
--
|
||||||
this.Slider = Util.GetGameObject(self.gameObject, "Slider"):GetComponent("Slider")
|
this.Slider = Util.GetGameObject(self.gameObject, "Slider"):GetComponent("Slider")
|
||||||
this.Tip = Util.GetGameObject(self.gameObject, "Slider/Image/LoadingText"):GetComponent("Text")
|
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")
|
this.SliderText = Util.GetGameObject(self.gameObject, "Slider/Fill Area/Fill/Image/Text"):GetComponent("Text")
|
||||||
this.bg = Util.GetGameObject(self.gameObject, "bg1"):GetComponent("Image")
|
this.bg = Util.GetGameObject(self.gameObject, "bg1"):GetComponent("Image")
|
||||||
this.heroPos=Util.GetGameObject(self.gameObject, "heroPos")
|
this.heroPos = Util.GetGameObject(self.gameObject, "heroPos")
|
||||||
screenAdapte(Util.GetGameObject(self.gameObject, "bg1"))
|
screenAdapte(Util.GetGameObject(self.gameObject, "bg1"))
|
||||||
screenAdapte(Util.GetGameObject(self.gameObject, "bg2"))
|
screenAdapte(Util.GetGameObject(self.gameObject, "bg2"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function LoadingPanel:OnOpen(sp)
|
function LoadingPanel:OnOpen()
|
||||||
local index = 0
|
local index = 0
|
||||||
this.bg.sprite = sp
|
--this.bg.sprite = sp
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
index = math.random(1,16)
|
index = math.random(1, 16)
|
||||||
this.Tip.text = GetLanguageStrById(tipsConfig[index].Tips)
|
this.Tip.text = GetLanguageStrById(tipsConfig[index].Tips)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 销毁时回收
|
-- 销毁时回收
|
||||||
function LoadingPanel:OnDestroy()
|
function LoadingPanel:OnDestroy()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local callList = {}
|
local callList = {}
|
||||||
local curIndex = 0
|
local curIndex = 0
|
||||||
local lerp = 0
|
local lerp = 0
|
||||||
local maxIndex = 0
|
local maxIndex = 0
|
||||||
local function update()
|
local function update()
|
||||||
if this.Slider and this.SliderText then
|
if this.Slider and this.SliderText then
|
||||||
lerp = math.clamp(lerp + Time.fixedDeltaTime * 15,0,1)
|
lerp = math.clamp(lerp + Time.fixedDeltaTime * 15, 0, 1)
|
||||||
local curValue = this.Slider.value * (1-lerp) + curIndex * lerp
|
local curValue = this.Slider.value * (1 - lerp) + curIndex * lerp
|
||||||
this.Slider.value = curValue
|
this.Slider.value = curValue
|
||||||
local curTextValue = math.ceil((curValue/this.Slider.maxValue)*100)
|
local curTextValue = math.ceil((curValue / this.Slider.maxValue) * 100)
|
||||||
curTextValue = curTextValue > 100 and 100 or curTextValue
|
curTextValue = curTextValue > 100 and 100 or curTextValue
|
||||||
this.SliderText.text = curTextValue .."%"
|
this.SliderText.text = curTextValue .. "%"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function LoadingPanel.AddStep(func)
|
function LoadingPanel.AddStep(func)
|
||||||
table.insert(callList, func)
|
table.insert(callList, func)
|
||||||
maxIndex = maxIndex + 1
|
maxIndex = maxIndex + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function LoadingPanel.OnStep()
|
function LoadingPanel.OnStep()
|
||||||
lerp = 0
|
lerp = 0
|
||||||
|
|
@ -61,12 +63,11 @@ end
|
||||||
function LoadingPanel.ErrorStep(msg)
|
function LoadingPanel.ErrorStep(msg)
|
||||||
--
|
--
|
||||||
if curIndex >= maxIndex then return end
|
if curIndex >= maxIndex then return end
|
||||||
LogError("登录接口"..curIndex..", 报错:"..msg.errCode .. "|"..msg.errMsg)
|
LogError("登录接口" .. curIndex .. ", 报错:" .. msg.errCode .. "|" .. msg.errMsg)
|
||||||
-- 强制进入下一步
|
-- 强制进入下一步
|
||||||
LoadingPanel.OnStep()
|
LoadingPanel.OnStep()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function LoadingPanel.Start()
|
function LoadingPanel.Start()
|
||||||
-- 创建sprite加载器
|
-- 创建sprite加载器
|
||||||
this.spLoader = SpriteLoader.New()
|
this.spLoader = SpriteLoader.New()
|
||||||
|
|
@ -79,41 +80,42 @@ function LoadingPanel.Start()
|
||||||
-- spName = sprites[index]
|
-- spName = sprites[index]
|
||||||
-- end
|
-- end
|
||||||
--LoadStreamingTexture(this.spLoader, spName, function(sp)
|
--LoadStreamingTexture(this.spLoader, spName, function(sp)
|
||||||
if #callList <= 1 then
|
if #callList <= 1 then
|
||||||
return
|
return
|
||||||
|
end
|
||||||
|
local heroConfig
|
||||||
|
for k, v in ConfigPairs(loadingConfig) do
|
||||||
|
configLen = configLen + 1
|
||||||
|
end
|
||||||
|
local spineLive = math.random(1, configLen)
|
||||||
|
local curLoad = ConfigManager.TryGetConfigData(ConfigName.Loading, spineLive)
|
||||||
|
if curLoad then
|
||||||
|
if spineObj ~= nil and spineName ~= nil then
|
||||||
|
poolManager:UnLoadLive(spineName, spineObj, PoolManager.AssetType.GameObject)
|
||||||
end
|
end
|
||||||
local heroConfig
|
heroConfig = ConfigManager.TryGetConfigData(ConfigName.HeroConfig, curLoad.Hero)
|
||||||
for k,v in ConfigPairs(loadingConfig) do
|
spName = curLoad.LoadingBG
|
||||||
configLen=configLen+1
|
end
|
||||||
end
|
UIManager.OpenPanel(UIName.LoadingPanel)
|
||||||
local spineLive=math.random(1,configLen)
|
--LogError("heroconfig i================="..heroConfig[10001].Id.." len==="..#heroConfig)
|
||||||
local curLoad=ConfigManager.TryGetConfigData(ConfigName.Loading,spineLive)
|
|
||||||
if curLoad then
|
if heroConfig then
|
||||||
if spineObj~=nil and spineName~=nil then
|
spineName = GetResourcePath(heroConfig.Live)
|
||||||
poolManager:UnLoadLive(spineName, spineObj, PoolManager.AssetType.GameObject)
|
spineObj = poolManager:LoadLive(spineName, this.heroPos.transform, Vector3.one * heroConfig.Scale,
|
||||||
end
|
Vector3.New(heroConfig.Position[1], heroConfig.Position[2], 0))
|
||||||
heroConfig=ConfigManager.TryGetConfigData(ConfigName.HeroConfig,curLoad.Hero)
|
spineObj.transform:SetParent(this.heroPos.transform)
|
||||||
spName=curLoad.LoadingBG
|
-- spineObj.transform.localPosition = Vector2.New(0, -20)
|
||||||
end
|
-- spineObj.transform.localScale=Vector3.one
|
||||||
UIManager.OpenPanel(UIName.LoadingPanel,this.spLoader:LoadSprite(spName))
|
end
|
||||||
--LogError("heroconfig i================="..heroConfig[10001].Id.." len==="..#heroConfig)
|
UpdateBeat:Add(update)
|
||||||
|
lerp = 0
|
||||||
if heroConfig then
|
curIndex = 0
|
||||||
spineName=GetResourcePath(heroConfig.Live)
|
this.Slider.maxValue = #callList - 1
|
||||||
spineObj= poolManager:LoadLive(spineName,this.heroPos.transform, Vector3.one * heroConfig.Scale, Vector3.New(heroConfig.Position[1], heroConfig.Position[2], 0))
|
this.Slider.value = curIndex
|
||||||
spineObj.transform:SetParent(this.heroPos.transform)
|
--"你知道嘛:充值会让你变得更强!" --"白驹工作室倾情奉献"
|
||||||
-- spineObj.transform.localPosition = Vector2.New(0, -20)
|
LoadingPanel.OnStep()
|
||||||
-- spineObj.transform.localScale=Vector3.one
|
--end
|
||||||
end
|
|
||||||
UpdateBeat:Add(update)
|
|
||||||
lerp = 0
|
|
||||||
curIndex = 0
|
|
||||||
this.Slider.maxValue = #callList - 1
|
|
||||||
this.Slider.value = curIndex
|
|
||||||
--"你知道嘛:充值会让你变得更强!" --"白驹工作室倾情奉献"
|
|
||||||
LoadingPanel.OnStep()
|
|
||||||
--end
|
|
||||||
|
|
||||||
--end)
|
--end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -121,12 +123,12 @@ function LoadingPanel.End()
|
||||||
UpdateBeat:Remove(update)
|
UpdateBeat:Remove(update)
|
||||||
this:ClosePanel()
|
this:ClosePanel()
|
||||||
callList = {}
|
callList = {}
|
||||||
if spineObj~=nil and spineName~=nil then
|
if spineObj ~= nil and spineName ~= nil then
|
||||||
poolManager:UnLoadLive(spineName, spineObj, PoolManager.AssetType.GameObject)
|
poolManager:UnLoadLive(spineName, spineObj, PoolManager.AssetType.GameObject)
|
||||||
end
|
end
|
||||||
spineName=nil
|
spineName = nil
|
||||||
spineObj=nil
|
spineObj = nil
|
||||||
this.spLoader:Destroy()
|
this.spLoader:Destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
return LoadingPanel
|
return LoadingPanel
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 928fd3985e8c04d4fa22136ad79aee4d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Reference in New Issue