121 lines
2.5 KiB
C#
121 lines
2.5 KiB
C#
using UnityEngine;
|
|
|
|
public class JVerifyManager : MonoBehaviour
|
|
{
|
|
public static JVerifyManager Instance;
|
|
|
|
private const string JavaClassName = "com.ldfpfgame.jverifybridge.JVerifyBridge";
|
|
private AndroidJavaClass _cls;
|
|
|
|
private string _initResult = "";
|
|
private string _preLoginResult = "";
|
|
private string _loginAuthResult = "";
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
gameObject.name = "JVerifyManager";
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
//Init();
|
|
Debug.Log("[JVerify] Manager ready, wait lua call Init()");
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
try
|
|
{
|
|
_cls = new AndroidJavaClass(JavaClassName);
|
|
_cls.CallStatic("setUnityObjectName", gameObject.name);
|
|
_cls.CallStatic("init");
|
|
Debug.Log("[JVerify] init called");
|
|
}
|
|
catch (System.Exception e)
|
|
{
|
|
Debug.LogError("[JVerify] init error: " + e);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
public void PreLogin(int timeout)
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
_cls?.CallStatic("preLogin", timeout);
|
|
#endif
|
|
}
|
|
|
|
public void LoginAuth()
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
_cls?.CallStatic("loginAuth");
|
|
#endif
|
|
}
|
|
|
|
public bool CheckEnable()
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
return _cls != null && _cls.CallStatic<bool>("checkVerifyEnable");
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
public void Dismiss()
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
_cls?.CallStatic("dismissLoginAuth", true);
|
|
#endif
|
|
}
|
|
|
|
public string GetInitResult()
|
|
{
|
|
return _initResult;
|
|
}
|
|
|
|
public string GetPreLoginResult()
|
|
{
|
|
return _preLoginResult;
|
|
}
|
|
|
|
public string GetLoginAuthResult()
|
|
{
|
|
return _loginAuthResult;
|
|
}
|
|
|
|
public void ClearInitResult()
|
|
{
|
|
_initResult = "";
|
|
}
|
|
|
|
public void ClearPreLoginResult()
|
|
{
|
|
_preLoginResult = "";
|
|
}
|
|
|
|
public void ClearLoginAuthResult()
|
|
{
|
|
_loginAuthResult = "";
|
|
}
|
|
|
|
public void OnJVerifyInit(string msg)
|
|
{
|
|
_initResult = msg;
|
|
Debug.Log("[JVerify] Init callback: " + msg);
|
|
}
|
|
|
|
public void OnJVerifyPreLogin(string msg)
|
|
{
|
|
_preLoginResult = msg;
|
|
Debug.Log("[JVerify] PreLogin callback: " + msg);
|
|
}
|
|
|
|
public void OnJVerifyLoginAuth(string msg)
|
|
{
|
|
_loginAuthResult = msg;
|
|
Debug.Log("[JVerify] LoginAuth callback: " + msg);
|
|
}
|
|
} |