【sdk】避免出现sdk初始化慢导致无法自动打开登录界面的问题

dev_chengFeng
gaoxin 2021-03-20 15:00:44 +08:00
parent cae60a1318
commit fccfeedba0
3 changed files with 16 additions and 2 deletions

View File

@ -438,5 +438,8 @@ GameEvent = {
UpdateGongMingLv= "HongMeng.UpdateGongMingLv", UpdateGongMingLv= "HongMeng.UpdateGongMingLv",
--鸿蒙碑新手引导 --鸿蒙碑新手引导
HongMengGuide = "HongMeng.HongMengGuide", HongMengGuide = "HongMeng.HongMengGuide",
},
SDK={
InitSuccess = "SDK.InitSuccess",
} }
} }

View File

@ -23,6 +23,11 @@ function this.Initialize()
this.isRegister = false this.isRegister = false
SDKMgr.onInitLaunchCallback = function(result)
if result == "1" then
Game.GlobalEvent:DispatchEvent(GameEvent.SDK.InitSuccess)
end
end
SDKMgr.onRegisterCallback = function() SDKMgr.onRegisterCallback = function()
this.isRegister = true this.isRegister = true
end end

View File

@ -125,22 +125,28 @@ function this:BindEvent()
end end
-- sdk 初始化完成回调
function this.OnInitSuccess()
this.sdkLoginBtn:SetActive(false)
this.SDKLogin()
end
--添加事件监听(用于子类重写) --添加事件监听(用于子类重写)
function this:AddListener() function this:AddListener()
Game.GlobalEvent:AddEvent(Protocal.Connect, this.OnConnect) Game.GlobalEvent:AddEvent(Protocal.Connect, this.OnConnect)
Game.GlobalEvent:AddEvent(Protocal.Disconnect, this.OnDisconnect) Game.GlobalEvent:AddEvent(Protocal.Disconnect, this.OnDisconnect)
Game.GlobalEvent:AddEvent(GameEvent.LoginSuccess.OnLoginSuccess, this.RefreshLoginStatus) Game.GlobalEvent:AddEvent(GameEvent.LoginSuccess.OnLoginSuccess, this.RefreshLoginStatus)
Game.GlobalEvent:AddEvent(GameEvent.LoginSuccess.OnLogout, this.OnLogout) Game.GlobalEvent:AddEvent(GameEvent.LoginSuccess.OnLogout, this.OnLogout)
Game.GlobalEvent:AddEvent(GameEvent.SDK.InitSuccess, this.OnInitSuccess)
end end
--移除事件监听(用于子类重写) --移除事件监听(用于子类重写)
function this:RemoveListener() function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(Protocal.Connect, this.OnConnect) Game.GlobalEvent:RemoveEvent(Protocal.Connect, this.OnConnect)
Game.GlobalEvent:RemoveEvent(Protocal.Disconnect, this.OnDisconnect) Game.GlobalEvent:RemoveEvent(Protocal.Disconnect, this.OnDisconnect)
Game.GlobalEvent:RemoveEvent(GameEvent.LoginSuccess.OnLoginSuccess, this.RefreshLoginStatus) Game.GlobalEvent:RemoveEvent(GameEvent.LoginSuccess.OnLoginSuccess, this.RefreshLoginStatus)
Game.GlobalEvent:RemoveEvent(GameEvent.LoginSuccess.OnLogout, this.OnLogout) Game.GlobalEvent:RemoveEvent(GameEvent.LoginSuccess.OnLogout, this.OnLogout)
Game.GlobalEvent:RemoveEvent(GameEvent.SDK.InitSuccess, this.OnInitSuccess)
end end
function this:OnLogout() function this:OnLogout()