XunJianDefault.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. using static LangChaoJiekou;
  6. using UnityEngine.UI;
  7. using XRTool.Util;
  8. public class XunJianDefault : MonoBehaviour
  9. {
  10. public Button noBtn;
  11. public Button yesBtn;
  12. public GameObject hintUI;
  13. public TMP_Text hintText;
  14. private bool isGetData;
  15. private void Start()
  16. {
  17. isGetData = false;
  18. noBtn.onClick.AddListener(() => { gameObject.SetActive(false); });
  19. yesBtn.onClick.AddListener(() => {
  20. if(isGetData)
  21. {
  22. // 进入巡检
  23. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowXunJian);
  24. hintUI.SetActive(false);
  25. gameObject.SetActive(false);
  26. }
  27. else if(!string.IsNullOrEmpty(hintText.text))
  28. {
  29. HintShow();
  30. }
  31. else
  32. {
  33. // 获取数据的回调未完成 等待完成
  34. return;
  35. }
  36. });
  37. }
  38. private void OnEnable()
  39. {
  40. hintUI.SetActive(false);
  41. if (XunJianAllData.taskItem == null)
  42. XunJianDataManager.Instance.checkXunjian((msg) =>
  43. {
  44. hintText.text = msg;
  45. isGetData = string.IsNullOrEmpty(msg);
  46. });
  47. }
  48. private void HintShow()
  49. {
  50. hintUI.gameObject.SetActive(true);
  51. TimerMgr.Instance.CreateTimer(() =>
  52. {
  53. hintUI.gameObject.SetActive(false);
  54. }, 3);
  55. gameObject.SetActive(false);
  56. }
  57. }