CSGPanel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System.Collections.Generic;
  2. using Excel2Json;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace Mono
  6. {
  7. [UIBinding(prefab = "CSGPanel")]
  8. public class CSGPanel : UIPanel
  9. {
  10. public Button Btn_DQ;
  11. public Button Btn_SR;
  12. public Button Btn_Return;
  13. public Button Btn_OnClick;
  14. public Button Btn_OnClick01;
  15. public RectTransform RegionScrollView;
  16. public RectTransform PoetScrollView;
  17. public RectTransform PoetContent;
  18. public RectTransform RegionContent;
  19. public RectTransform DQ;
  20. public RectTransform SR;
  21. public override void GetUIData()
  22. {
  23. Btn_DQ = UIData.Get<Button>("Btn_DQ");
  24. Btn_SR = UIData.Get<Button>("Btn_SR");
  25. Btn_Return = UIData.Get<Button>("Btn_Return");
  26. Btn_OnClick = UIData.Get<Button>("Btn_OnClick");
  27. Btn_OnClick01 = UIData.Get<Button>("Btn_OnClick01");
  28. RegionScrollView = UIData.Get<RectTransform>("RegionScrollView");
  29. PoetScrollView = UIData.Get<RectTransform>("PoetScrollView");
  30. PoetContent = UIData.Get<RectTransform>("PoetContent");
  31. RegionContent = UIData.Get<RectTransform>("RegionContent");
  32. DQ = UIData.Get<RectTransform>("DQ");
  33. SR = UIData.Get<RectTransform>("SR");
  34. }
  35. public override void AddButtonEvent()
  36. {
  37. Btn_DQ.onClick.AddListener(() =>
  38. {
  39. DQ.gameObject.SetActive(true);
  40. SR.gameObject.SetActive(false);
  41. UIManager.Instance.PlayAudioClip("UI_OpenPage");
  42. });
  43. Btn_SR.onClick.AddListener(() =>
  44. {
  45. DQ.gameObject.SetActive(false);
  46. SR.gameObject.SetActive(true);
  47. UIManager.Instance.PlayAudioClip("UI_OpenPage");
  48. });
  49. Btn_Return.onClick.AddListener(() =>
  50. {
  51. UIManager.Instance.HideUIPanel<CSGPanel>();
  52. UIManager.Instance.LoadAndOpenPanel<MainScenePanel>(UIManager.UILayer.Middle);
  53. UIManager.Instance.PlayAudioClip("UI_Close");
  54. });
  55. Btn_OnClick.onClick.AddListener(() =>
  56. {
  57. UIManager.Instance.HideUIPanel<CSGPanel>();
  58. UIManager.Instance.LoadAndOpenPanel<ChatPanel>(UIManager.UILayer.Middle);
  59. });
  60. Btn_OnClick01.onClick.AddListener(() =>
  61. {
  62. UIManager.Instance.HideUIPanel<CSGPanel>();
  63. UIManager.Instance.LoadAndOpenPanel<ChatPanel>(UIManager.UILayer.Middle);
  64. });
  65. }
  66. public override void Show()
  67. {
  68. base.Show();
  69. //CustomInit();
  70. }
  71. public List<RegionItem> RegionItems = new List<RegionItem>();
  72. public void CustomInit()
  73. {
  74. for (var i = 0; i < RegionItems.Count; i++)
  75. {
  76. UIManager.Instance.RecUICom(this, RegionItems[i]);
  77. }
  78. RegionItems.Clear();
  79. RegionConfig[] regionConfigs = ConfigComponent.Instance.GetAll<RegionConfig>();
  80. for (var i = 0; i < regionConfigs.Length; i++)
  81. {
  82. RegionItem regionItem = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
  83. regionItem.CustomInit(regionConfigs[i]);
  84. RegionItems.Add(regionItem);
  85. }
  86. // RegionItem regionItem = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
  87. // regionItem.CustomInit("江津");
  88. //
  89. // RegionItem regionItem1 = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
  90. // regionItem1.CustomInit("北碚");
  91. //
  92. // RegionItem regionItem2 = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
  93. // regionItem2.CustomInit("合川");
  94. }
  95. }
  96. }