using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIBagInfo : UIWindow { public Transform rectTransfrom; public ItemTip tip; private void Awake() { tip.gameObject.SetActive(false); } private void OnEnable() { PlayerInfo.Instance.OnUpdateBagInfo += UpdateUI; UpdateUI(); } private void OnDisable() { PlayerInfo.Instance.OnUpdateBagInfo -= UpdateUI; tip.gameObject.SetActive(false); } public void UpdateUI() { foreach (Transform item in rectTransfrom) { Destroy(item.gameObject); } foreach (var item in PlayerInfo.Instance.info.BagInfo) { string path = "UI/Perfab/Item"; UnityEngine.Object go = Resloader.Load(path); if (go != null) { GameObject m = (GameObject)Instantiate(go, rectTransfrom); UIItemInfo ui = m.GetComponent(); ui.gameObject.SetActive(true); ui.SetInfo(item.Key, item.Value,this); } } } public void ShowItem(Item item) { tip.gameObject.SetActive(true); tip.Init(item); } }