LoadingPanel.cs 3.5 KB

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