ShuJuYuanGuanLi.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using static Manager;
  6. public class ShuJuYuanGuanLi : MonoBehaviour
  7. {
  8. public Toggle xst;
  9. public Toggle yct;
  10. public Toggle yt;
  11. public Toggle zt;
  12. public Toggle dt;
  13. public Text dqsj;
  14. public Toggle bzt;
  15. public Toggle bst;
  16. public Toggle szt;
  17. public Toggle sst;
  18. public GameObject go;
  19. public List<GameObject> golist;
  20. private void Awake()
  21. {
  22. yt.onValueChanged.AddListener((b) => {
  23. if(b&& ainfo!=null)
  24. {
  25. refinfo(ainfo.yunneng_option);
  26. }
  27. });
  28. zt.onValueChanged.AddListener((b) => {
  29. if (b && ainfo != null)
  30. {
  31. refinfo(ainfo.zongji_ption);
  32. }
  33. });
  34. dt.onValueChanged.AddListener((b) => {
  35. if (b && ainfo != null)
  36. {
  37. refinfo(ainfo.donghuan_option);
  38. }
  39. });
  40. }
  41. private void OnDestroy()
  42. {
  43. yt.onValueChanged.RemoveAllListeners();
  44. zt.onValueChanged.RemoveAllListeners();
  45. dt.onValueChanged.RemoveAllListeners();
  46. }
  47. public void refinfo(Toption t)
  48. {
  49. for (int i = 0; i < golist.Count; i++)
  50. {
  51. Destroy(golist[i]);
  52. }
  53. switch(t.current_data_source)
  54. {
  55. case 1:
  56. dqsj.text = "云能智维实时数据";
  57. dqsj.color = Color.green;
  58. break;
  59. default:
  60. dqsj.text = "云能智维备份数据";
  61. dqsj.color = new Color(277,115,24,255);
  62. break;
  63. }
  64. bzt.isOn = t.backup_data_switch_type == 1 ? true : false;
  65. bst.isOn = t.backup_data_switch_type != 1 ? true : false;
  66. szt.isOn = t.data_recover_type == 1 ? true : false;
  67. sst.isOn = t.data_recover_type != 1 ? true : false;
  68. for (int i = 0; i <t.details.Count; i++)
  69. {
  70. GameObject ngo= GameObject.Instantiate(go, go.transform.parent);
  71. ngo.SetActive(true);
  72. ngo.GetComponent<ShuJuYuanItem>().init(t.details[i]);
  73. golist.Add(ngo);
  74. }
  75. }
  76. AdminsystemInfo ainfo;
  77. private void OnEnable()
  78. {
  79. if(DataManager.Instance)
  80. {
  81. DataManager.Instance.getInfo((msg) => {
  82. ainfo = msg;
  83. xst.isOn = msg.general_option.update_time_display_switch;
  84. yct.isOn = !msg.general_option.update_time_display_switch;
  85. yt.isOn = true;
  86. refinfo(msg.yunneng_option);
  87. });
  88. }
  89. }
  90. }