WidgetItem.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using Core.Language;
  3. using Fort23.UTool;
  4. using GameLogic.Bag;
  5. using GameLogic.Equipment;
  6. using UnityEngine;
  7. using Utility;
  8. namespace Fort23.Mono
  9. {
  10. [UIBinding(prefab = "WidgetItem")]
  11. public partial class WidgetItem : UIComponent
  12. {
  13. public ItemInfo itemInfo;
  14. private void Init()
  15. {
  16. }
  17. public override void AddEvent()
  18. {
  19. }
  20. public override void DelEvent()
  21. {
  22. }
  23. public override void AddButtonEvent()
  24. {
  25. btnClick.onClick.AddListener(OnclickItem);
  26. }
  27. private Action onClickItem;
  28. private async void OnclickItem()
  29. {
  30. if (onClickItem != null)
  31. {
  32. onClickItem.Invoke();
  33. return;
  34. }
  35. if (itemInfo == null)
  36. {
  37. return;
  38. }
  39. // ItemPanel itemPanel = await UIManager.Instance.LoadAndOpenPanel<ItemPanel>(null, layer: UILayer.Top);
  40. // itemPanel.InitItemPanel(itemInfo);
  41. }
  42. public void InitWidget(ItemInfo itemInfo, Action onClickItem = null)
  43. {
  44. this.itemInfo = itemInfo;
  45. this.onClickItem = onClickItem;
  46. border.gameObject.SetActive(false);
  47. light.gameObject.SetActive(false);
  48. icon.gameObject.SetActive(true);
  49. if (itemInfo.count.Value > 0)
  50. {
  51. numObj.SetActive(true);
  52. num.text = itemInfo.count.Value.ToStringEx();
  53. }
  54. else
  55. {
  56. numObj.SetActive(false);
  57. }
  58. }
  59. }
  60. }