TopManager.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using LitJson;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using TMPro;
  6. using System;
  7. public class TopManager : MonoSingleton<TopManager>
  8. {
  9. public GameObject root;
  10. public GameObject icon;
  11. public TMP_Text timeText;
  12. private DateTime times;
  13. private Coroutine timeCoroutine;
  14. public void exitUser()
  15. {
  16. List<string> backTip = new List<string>();
  17. JsonData data = new JsonData();
  18. data["type"] = "40001";
  19. backTip.Add("1");
  20. backTip.Add(data.ToJson());
  21. backTip.Add("3");
  22. WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "是否退出账号?", Color.gray, "icon", backTip, false, "自动退出", 5, "", "退出", "返回").ToJson());
  23. }
  24. public void exitUserOk()
  25. {
  26. if (ChangeCameraSaoMiao.Instance)
  27. {
  28. ChangeCameraSaoMiao.Instance.close();
  29. ChangeCameraSaoMiao.Instance.checkLuXiang();
  30. }
  31. if (LineManager.Instance)
  32. LineManager.Instance.stop();
  33. if (WindowGenSui.Instance)
  34. WindowGenSui.Instance.jd = 30;
  35. LoginManager.Instance.ExitUser();
  36. WindowsManager.Instance.show(WindowConfig.windowType.Login);
  37. }
  38. private void OnEnable()
  39. {
  40. if (TopManager.Instance.icon.transform.localPosition != Vector3.zero)
  41. {
  42. TopManager.Instance.root.SetActive(false);
  43. UserManager.Instance.MoveIcon(Vector3.zero, TopManager.Instance.icon.transform, () => { TopManager.Instance.root.SetActive(true); });
  44. }
  45. timeCoroutine= StartCoroutine(UpdataTimer());
  46. }
  47. private void OnDisable()
  48. {
  49. StopCoroutine(timeCoroutine);
  50. }
  51. private IEnumerator UpdataTimer()
  52. {
  53. while (true)
  54. {
  55. yield return new WaitForSeconds(1f);
  56. times = GetHttpTimer.Instance.GetTimer();
  57. //Debug.Log(times);
  58. //Debug.Log(times.Hour + ":" + times.Minute);
  59. timeText.text = times.Hour + ":" + times.Minute;
  60. }
  61. }
  62. }