跳到主要内容

LI PASS 事件回调信息(LIEventObserver)

如果您使用的是 Unreal Engine,请参见 Unreal Engine SDK 的 LIEventObserver

LI PASS 事件的回调,游戏需要处理回调逻辑。当 LI PASS 初始化完成时,将触发回调。更多回调数据结构的信息,请参见 LIBaseEventResult

注意

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

函数定义

// 添加回调
public static void AddLIEventObserver(OnLIEventResultHandler<LIBaseEventResult> liEvent)

// 移除回调
public static void RemoveLIEventObserver(OnLIEventResultHandler<LIBaseEventResult> liEvent)

代码示例

// 添加回调
LevelInfinite.AddLIEventObserver(OnLIBaseEventResult);
// 处理 LIEventObserver 的回调结果
private void OnLIBaseEventResult(LIBaseEventResult liRet)
{
Debug.Log("<color=#ff00ff>OnLIBaseEventResult. lIEventType : " + Enum.GetName(typeof(LIEventType), liRet.lIEventType) + ", extraJson:" + liRet.extraJson + "</color>");
ShowLogInNewLine("OnLIBaseEventResult. lIEventType : " + Enum.GetName(typeof(LIEventType), liRet.lIEventType) + ", extraJson:" + liRet.extraJson);
switch (liRet.lIEventType)
{
case LIEventType.DEFAULT:
break;
// LI PASS Init Finish
case LIEventType.GN_READY:
try
{
GNPanelReadyEventParam param = JsonUtility.FromJson<GNPanelReadyEventParam>(liRet.extraJson);
ShowLogInNewLine("<color=#ff0000>Version</color> : " + param.extraParams.asset_version + "\n Is_CDN_Asset:" + param.extraParams.is_cdn_asset.ToString());
}
catch (Exception e)
{
Debug.LogError("On LIEventType.INTL_READY Error. msg:" + e.ToString());
}
break;
// LI PASS Panel Open
case LIEventType.LIP_PANEL_OPEN:
try
{
GNPanelCreatedEventParam param = JsonUtility.FromJson<GNPanelCreatedEventParam>(liRet.extraJson);
ShowLogInNewLine("Open Panel from Module:" + param.module + "\n"+
"panelName:" + param.extraParams.panelName.ToString()+"\n"+
"extraJson:" + param.extraParams.extraJson.ToString()+"\n");
}
catch (Exception e)
{
Debug.LogError("On LIEventType.LIP_PANEL_OPEN Error. msg:" + e.ToString());
}
break;
// LI PASS Panel Close
case LIEventType.LIP_PANEL_CLOSE:
try
{
GNPanelCloseEventParam param = JsonUtility.FromJson<GNPanelCloseEventParam>(liRet.extraJson);
ShowLogInNewLine("CLOSE Panel from Module:" + param.module + "\n"+
"isPopPanel:" + param.isPopPanel.ToString() +"\n" +
"isInsertPanel:" + param.isInsertPanel.ToString() +"\n" +
"panelName:" + param.extraParams.panelName.ToString()+"\n"+
"isClosedManually:" + param.extraParams.isClosedManually.ToString()+"\n"+
"extraJson:" + param.extraParams.extraJson.ToString()+"\n");
ResetFocus();
Debug.LogError("reset focus");
}
catch (Exception e)
{
Debug.LogError("On LIEventType.LIP_PANEL_CLOSE " + liRet.lIEventType.ToString() + "Error. msg:" + e.ToString());
}
break;
// LI PASS Open Login Panel
case LIEventType.OPEN_LOGIN:
break;
// LI PASS Close Login Panel
case LIEventType.CLOSE_LOGIN:
break;
// LI PASS Open Account Center
case LIEventType.OPEN_ACCOUNT_CENTER:
break;
// LI PASS Close Account Center
case LIEventType.CLOSE_ACCOUNT_CENTER:
break;
// LI PASS Close Delete Account Panel
case LIEventType.CLOSE_DELETE_ACCOUNT:
break;
// LI PASS Close Parent Certificate Panel
case LIEventType.CLOSE_PARENT_CERTIFICATE:
break;
// LI PASS Close Parent Tip Panel
case LIEventType.CLOSE_PARENT_TIP:
break;
// LI PASS Close Parent Deny Panel
case LIEventType.CLOSE_PARENT_DENY:
try
{
GNPanelCloseEventParam param = JsonUtility.FromJson<GNPanelCloseEventParam>(liRet.extraJson);
ShowLogInNewLine("CLOSE Panel from Module:" + param.module + "\n"+
"isPopPanel:" + param.isPopPanel.ToString() +"\n" +
"isInsertPanel:" + param.isInsertPanel.ToString() +"\n" +
"panel_name:" + param.extraParams.panel_name.ToString()+"\n");
ResetFocus();
Debug.LogError("reset focus");
}
catch (Exception e)
{
Debug.LogError("On LIEventType.CLOSE Panel" + liRet.lIEventType.ToString() + "Error. msg:" + e.ToString());
}
break;
// LI PASS Delete Account Success, this LIEventType takes effect for LI PASS V1.14.00 and later version in Unity.
case LIEventType.DELETE_ACCOUNT_SUCCESS:
Debug.Log("LIEventType.DELETE_ACCOUNT_SUCCESS");
break;
// LI PASS Delete Account Parameters Missing, this LIEventType takes effect for LI PASS V1.14.00 and later version in Unity.
case LIEventType.DELETE_PARAMETERS_MISSING:
break;
// LI PASS Delete Account Failed, this LIEventType takes effect for LI PASS V1.14.00 and later version in Unity.
case LIEventType.DELETE_ACCOUNT_FAIL:
Debug.Log("LIEventType.DELETE_ACCOUNT_FAIL");
break;
// Authorization status of messaging for minors
case LIEventType.SOCIAL_FEATURE_APPROVE_STATUS:
try
{
LISocialFeatureApproveStatus param = JsonUtility.FromJson<LISocialFeatureApproveStatus>(liRet.extraJson);
ShowLogInNewLine("SOCIAL_FEATURE_APPROVE_STATUS, VoiceControlStatus:" + param.VoiceControlStatus + ", NeedVoiceControl:" + param.NeedVoiceControl + ", NeedVoiceVontrolIngame:" + param.NeedVoiceControlIngame + ", NeedVoiceControlParentCert:" + param.NeedVoiceControlParentCert);
}
catch (Exception e)
{
Debug.LogError("On LIEventType.SOCIAL_FEATURE_APPROVE_STATUS" + liRet.lIEventType.ToString() + "Error. msg:" + e.ToString());
}
break;
// Authorization result of messaging for minors
case LIEventType.SOCIAL_FEATURE_APPROVE_RESULT:
try
{
LISocialFeatureApproveResult param = JsonUtility.FromJson<LISocialFeatureApproveResult>(liRet.extraJson);
ShowLogInNewLine("SOCIAL_FEATURE_APPROVE_RESULT, VoiceControlStatus: " + param.VoiceControlStatus);
}
catch (Exception e)
{
Debug.LogError("On LIEventType.SOCIAL_FEATURE_APPROVE_RESULT" + liRet.lIEventType.ToString() + "Error. msg:" + e.ToString());
}
break;
// LI PASS Init Repeat
case LIEventType.GN_REPEAT:
break;
// LI PASS Closed
case LIEventType.GN_DISABLED:
break;
default:
break;
}
}
// 移除回调
LevelInfinite.RemoveLIEventObserver(OnLIBaseEventResult);