ShuJuYuanItem.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using static Manager;
  6. public class ShuJuYuanItem : MonoBehaviour
  7. {
  8. public Text t1;
  9. public Text t2;
  10. public Text t3;
  11. public Text t4;
  12. public Text t5;
  13. public Toggle tg1;
  14. public Toggle tg2;
  15. public GameObject go;
  16. public Text numtext;
  17. public void init(Detail d)
  18. {
  19. t1.text = d.name;
  20. t2.text = d.update_rate_display;
  21. switch (d.current_data_source)
  22. {
  23. case 1:
  24. t3.text = "云能智维实时数据";
  25. t3.color = Color.green;
  26. break;
  27. default:
  28. t3.text = "云能智维备份数据";
  29. t3.color = new Color(277, 115, 24, 255);
  30. break;
  31. }
  32. t4.text = d.check_time;
  33. t5.text = d.real_data_status == 1 ? "正常" : "不正常";
  34. t5.color = d.real_data_status == 1 ?Color.green : Color.red;
  35. tg1.isOn = d.update_rate_type == 2 ? false : true;
  36. tg2.isOn = d.update_rate_type != 2 ? false : true;
  37. num = d.update_Rate_value;
  38. if (num <= 1)
  39. {
  40. removeb.interactable = false;
  41. }
  42. else
  43. {
  44. removeb.interactable = true;
  45. }
  46. if (num >= 24)
  47. {
  48. addb.interactable = false;
  49. }
  50. else
  51. {
  52. addb.interactable = true;
  53. }
  54. numtext.text = num.ToString();
  55. go.SetActive(tg2.isOn);
  56. tg2.onValueChanged.RemoveAllListeners();
  57. tg2.onValueChanged.AddListener((b)=> {
  58. go.SetActive(b);
  59. });
  60. }
  61. int num = 1;
  62. public Button addb;
  63. public Button removeb;
  64. public void changenum(int i)
  65. {
  66. num += i;
  67. if(num <=1)
  68. {
  69. removeb.interactable = false;
  70. }
  71. else
  72. {
  73. removeb.interactable = true;
  74. }
  75. if (num >= 24)
  76. {
  77. addb.interactable = false;
  78. }
  79. else
  80. {
  81. addb.interactable = true;
  82. }
  83. numtext.text = num.ToString();
  84. }
  85. }