1
This commit is contained in:
53
unity/Assets/Script/UI/Bag/UIBagInfo.cs
Normal file
53
unity/Assets/Script/UI/Bag/UIBagInfo.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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<GameObject>(path);
|
||||
if (go != null)
|
||||
{
|
||||
GameObject m = (GameObject)Instantiate(go, rectTransfrom);
|
||||
UIItemInfo ui = m.GetComponent<UIItemInfo>();
|
||||
ui.gameObject.SetActive(true);
|
||||
|
||||
ui.SetInfo(item.Key, item.Value,this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowItem(Item item)
|
||||
{
|
||||
tip.gameObject.SetActive(true);
|
||||
tip.Init(item);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user