/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using FairyGUI; using FL.Data; using XGame.Framework.UI; namespace FL.FGUI { /// /// UI逻辑处理类 /// /// public partial class PartnerCostLabelCtrl : UIController { 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}"; } } }