AuthenticationTest.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class AuthenticationTest : MonoBehaviour
  6. {
  7. public Text text;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. //PlayerPrefs.DeleteAll();
  12. AuthenticationManager.Instance.onAuthenticationEventCallback += OnAuthenticationInfoCallback;
  13. }
  14. private void OnDestroy()
  15. {
  16. AuthenticationManager.Instance.onAuthenticationEventCallback -= OnAuthenticationInfoCallback;
  17. }
  18. public void GetAuthenticationInfo()
  19. {
  20. Debug.Log("GetAuthenticationInfo: CLICK");
  21. AuthenticationManager.Instance.GetAuthenticationInfo();
  22. }
  23. public void GeAuthenticationInfoForTest()
  24. {
  25. AuthenticationManager.Instance.GetAuthenticationInfo();
  26. }
  27. private void OnAuthenticationInfoCallback(AuthenticationEvent authenticationEvent, string message)
  28. {
  29. string result = string.Empty;
  30. switch (authenticationEvent)
  31. {
  32. case AuthenticationEvent.NetworkAuthenticationOK:
  33. result = "联网鉴权成功";
  34. break;
  35. case AuthenticationEvent.LocalAuthenticationOK:
  36. result = "本地鉴权成功";
  37. break;
  38. case AuthenticationEvent.GetChannelPackageNameFail:
  39. result = "获取个人中心包名失败";
  40. break;
  41. case AuthenticationEvent.NetworkAuthenticationFail:
  42. result = "联网鉴权失败";
  43. break;
  44. case AuthenticationEvent.CannotGetChannelUserId:
  45. result = "无法获取个人中心用户信息(无网时)";
  46. break;
  47. case AuthenticationEvent.NoAuthenticationDataInLocal:
  48. result = "本地无缓存鉴权信息,需要联网";
  49. break;
  50. case AuthenticationEvent.ChannelUserIdNotMatch:
  51. result = "本地健全信息与个人中心用户信息不一致(需要联网)";
  52. break;
  53. case AuthenticationEvent.LocalAuthenticationExpire:
  54. result = "无网状态本地鉴权信息已过期";
  55. break;
  56. }
  57. text.text = "鉴权结果:" + result + "\n额外信息:" + message;
  58. }
  59. }