123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System.Collections.Generic;
- using Excel2Json;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Mono
- {
- [UIBinding(prefab = "RegionItem")]
- public class RegionItem : UICom
- {
- public Button Btn_Region;
- public Text Text_RegionName;
- public RectTransform PoetryItemRoot;
- public List<PoetryItem> CurPoetryItems = new List<PoetryItem>();
- public override void GetUIData()
- {
- Btn_Region = UIData.Get<Button>("Btn_Region");
- Text_RegionName = UIData.Get<Text>("Text_RegionName");
- PoetryItemRoot = UIData.Get<RectTransform>("PoetryItemRoot");
- }
- public override void AddButtonEvent()
- {
- Btn_Region.onClick.AddListener(() => { CreatPoetryItem(); });
- }
- public void CreatPoetryItem()
- {
- if (CurPoetryItems.Count > 0)
- {
- for (var i = 0; i < CurPoetryItems.Count; i++)
- {
- UIManager.Instance.RecUICom(this, CurPoetryItems[i]);
- }
- CurPoetryItems.Clear();
- return;
- }
- for (var i = 0; i < RegionConfig.Poets.Length; i++)
- {
- PoetConfig poetConfig = ConfigComponent.Instance.Get<PoetConfig>(RegionConfig.Poets[i]);
- PoetryItem poetryItem = UIManager.Instance.CreatUICom<PoetryItem>(this, PoetryItemRoot);
- poetryItem.CustomInit(poetConfig);
- CurPoetryItems.Add(poetryItem);
- }
- // PoetryItem poetryItem = UIManager.Instance.CreatUICom<PoetryItem>(this, PoetryItemRoot);
- // poetryItem.CustomInit("白帝");
- // CurPoetryItems.Add(poetryItem);
- // PoetryItem poetryItem1 = UIManager.Instance.CreatUICom<PoetryItem>(this, PoetryItemRoot);
- // poetryItem1.CustomInit("黑帝");
- // CurPoetryItems.Add(poetryItem1);
- // PoetryItem poetryItem2 = UIManager.Instance.CreatUICom<PoetryItem>(this, PoetryItemRoot);
- // poetryItem2.CustomInit("金帝");
- // CurPoetryItems.Add(poetryItem2);
- }
- public override void Show()
- {
- base.Show();
- }
- public RegionConfig RegionConfig;
- public void CustomInit(RegionConfig regionConfig)
- {
- RegionConfig = regionConfig;
- Text_RegionName.text = regionConfig.name;
- }
- }
- }
|