LoadingPanel.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using Blue;
  2. using LitJson;
  3. using Newtonsoft.Json.Linq;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Threading;
  8. using UnityEngine;
  9. using UnityEngine.UI;
  10. public enum ELoadState
  11. {
  12. login,//登录
  13. getAllScene,//获取账号下所有场景
  14. sninfo,//绑定设备
  15. sninfoEnd,//绑定设备完成
  16. sceneChoose,//场景选择
  17. getMaterialValue,//获取素材库
  18. download,// 更新下载
  19. createScene,// 生成场景
  20. updateEnd,// 更新完成
  21. SaveSpoitData, //更新景点数据
  22. SaveSpoitDataEnd,
  23. }
  24. public class LoadingPanel : BaseUI
  25. {
  26. private Text m_Text;
  27. private string m_TextStr;
  28. private Text m_Progress;
  29. private string m_ProgressStr;
  30. public string TextStr
  31. {
  32. get { return m_TextStr; }
  33. set
  34. {
  35. m_TextStr = value;
  36. if (m_Text != null)
  37. {
  38. m_Text.text = m_TextStr;
  39. }
  40. }
  41. }
  42. public string ProgressStr
  43. {
  44. get { return ProgressStr; }
  45. set
  46. {
  47. m_ProgressStr = value;
  48. if (m_Progress != null)
  49. {
  50. m_Progress.text = m_ProgressStr;
  51. }
  52. }
  53. }
  54. protected override void OnAwake()
  55. {
  56. base.OnAwake();
  57. m_Text = CacheTransform.Find("Text").GetComponent<Text>();
  58. m_Progress = CacheTransform.Find("Progress").GetComponent<Text>();
  59. ProgressStr = "";
  60. this.SendCommand(new GetGameObjectCommand(gameObject));
  61. }
  62. protected override void OnShow(object param)
  63. {
  64. base.OnShow(param);
  65. transform.localPosition = new Vector3(0, 0, -25f);
  66. int state = (int)param;
  67. OnStateChange(state);
  68. }
  69. private void OnStateChange(int state)
  70. {
  71. switch (state)
  72. {
  73. case (int)ELoadState.login:
  74. m_Text.text = "正在登录";
  75. break;
  76. case (int)ELoadState.sninfo:
  77. m_Text.text = "正在绑定设备";
  78. break;
  79. case (int)ELoadState.sninfoEnd:
  80. m_Text.text = "";
  81. break;
  82. case (int)ELoadState.sceneChoose:
  83. m_Text.text = "获取当前选择场景数据";
  84. break;
  85. case (int)ELoadState.getMaterialValue:
  86. m_Text.text = "获取素材库数据";
  87. break;
  88. case (int)ELoadState.download:
  89. m_Text.text = "正在更新素材库数据";
  90. break;
  91. case (int)ELoadState.getAllScene:
  92. m_Text.text = "获取账号下所有场景";
  93. break;
  94. case (int)ELoadState.createScene:
  95. m_Text.text = "正在创建场景";
  96. break;
  97. case (int)ELoadState.updateEnd:
  98. m_Text.text = "更新完成";
  99. StartCoroutine(UpdateEnd());
  100. break;
  101. case (int)ELoadState.SaveSpoitData:
  102. m_Text.text = "保存景点数据";
  103. break;
  104. case (int)ELoadState.SaveSpoitDataEnd:
  105. StartCoroutine(SaveDataEnd());
  106. break;
  107. default:
  108. break;
  109. }
  110. }
  111. IEnumerator UpdateEnd()
  112. {
  113. yield return new WaitForSeconds(1f);
  114. m_Text.text = "初始化场景";
  115. yield return new WaitForSeconds(1f);
  116. GameManager.Instance.IntoScene();
  117. Hide();
  118. }
  119. IEnumerator SaveDataEnd()
  120. {
  121. yield return new WaitForSeconds(1f);
  122. Hide();
  123. }
  124. protected override void OnDestroy()
  125. {
  126. base.OnDestroy();
  127. }
  128. }