LoadingPanel.cs 4.0 KB

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