Example.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Example : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. void Start()
  8. {
  9. API_Module_PlatformAccount.RegistLoginSuccessCallback(LoginSuccessCallback);
  10. API_Module_PlatformAccount.RegistLoginFailCallback(LoginFailedCallback);
  11. API_Module_PlatformAccount.RegisteLogoutSuccessCakkback(LogoutSuccessCallback);
  12. API_Module_PlatformAccount.RegisteLogoutSuccessCakkback(LogoutFailedCallback);
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. if (Input.GetKeyDown(KeyCode.L))
  18. {
  19. API_Module_PlatformAccount.Logout();
  20. }
  21. if (Input.GetKeyDown(KeyCode.R))
  22. {
  23. API_Module_PlatformAccount.RefreshUserData();
  24. }
  25. if (Input.GetKeyDown(KeyCode.U))
  26. {
  27. Debug.Log("UserData : " + JsonUtility.ToJson(API_Module_PlatformAccount.UserData));
  28. }
  29. if (Input.GetKeyDown(KeyCode.C))
  30. {
  31. API_Module_PlatformAccount.CheckUserState();
  32. }
  33. }
  34. private void OnDestroy()
  35. {
  36. API_Module_PlatformAccount.UnRegistLoginSuccessCallback(LoginSuccessCallback);
  37. API_Module_PlatformAccount.UnRegistLoginFailCallback(LoginFailedCallback);
  38. API_Module_PlatformAccount.UnRegisteLogoutSuccessCakkback(LogoutSuccessCallback);
  39. API_Module_PlatformAccount.UnRegisteLogoutSuccessCakkback(LogoutFailedCallback);
  40. }
  41. private void LoginSuccessCallback(string json)
  42. {
  43. Debug.Log("登录成功");
  44. }
  45. private void LoginFailedCallback(string json)
  46. {
  47. Debug.Log("登录失败");
  48. }
  49. private void LogoutSuccessCallback(string json)
  50. {
  51. Debug.Log("退出登录成功");
  52. }
  53. private void LogoutFailedCallback(string json)
  54. {
  55. Debug.Log("退出登录失败");
  56. }
  57. }