跳到主要内容

GUALoginResultObservers

[MSDK and Player Network SDK] 注册登录模块的回调,游戏需要对回调函数进行处理。更多关于回调数据结构,请参见 GUALoginResult

注意

强烈建议游戏在应用启动函数中进行注册。

函数定义

回调事件用于处理的方法列表

回调事件Common[仅限 Player Network SDK][仅限 MSD]
LoginResultEventsLogin,
Bind,
AutoLogin,
SwitchUser,
QueryUserInfo,
LoginWithConfirmCode
Register,
LoginWithMappedChannel,
BuildMapWithLoggedinChannel,
QueryLegalDocumentsAcceptedVersion,
LoginWithPassword,
LoginWithVerifyCode
BindUI,
Check,
CheckLogin,
BindWithConfirmCode
event OnResultHandler<GUALoginResult> LoginResultEvents;

代码示例

// 增加回调
UnionAdapterAPI.GetAccountService().LoginResultEvents += OnLoginResultEvent;

// 移除回调
UnionAdapterAPI.GetAccountService().LoginResultEvents -= OnLoginResultEvent;

// LoginResultEvents 的回调处理
public void OnLoginResultEvent(GUALoginResult loginRet)
{
Debug.Log("OnLoginResultEvent");
string methodTag = "";
if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_LOGIN)
{
methodTag = "Login";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_BIND)
{
methodTag = "Bind";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_AUTOLOGIN)
{
methodTag = "AutoLogin";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_SWITCH_USER)
{
methodTag = "SwitchUser";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_QUERY_USER_INFO)
{
methodTag = "QueryUserInfo";
}
Debug.Log("OnLoginResultEvent start format json");
Debug.Log(methodTag + loginRet);
}