1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerCostLabelCtrl : UIController<PartnerCostLabelVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- EventSingle.Instance.AddListener(EventDefine.UpdataItemData, OnItemUpdate);
- }
- private void RemoveUIListenres()
- {
- EventSingle.Instance.RemoveListener(EventDefine.UpdataItemData, OnItemUpdate);
- }
- private void OnItemUpdate(int eventId, object args)
- {
- ShowUI();
- }
- #endregion
- private int _id;
- private int _cost;
- public void SetData(int id, int costNum)
- {
- _id = id;
- _cost = costNum;
- ShowUI();
- }
- private void ShowUI()
- {
- var num = ItemData.Instance.GetItemNum(_id);
- VM.CountLabel.text = $"{num}/{_cost}";
- }
- }
- }
|