_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Scene_shop/itemInfo.cs

54 lines
1.1 KiB
C#
Raw Normal View History

2024-11-25 14:35:28 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class itemInfo : MonoBehaviour
{
[Header("<22><>ʾ<EFBFBD><CABE>Ʒ<EFBFBD><C6B7>image")]
public Image iconImage;
[Header("<22><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>TextPro")]
public TextMeshProUGUI nameText;
[Header("<22><>Ʒ<EFBFBD>۸<EFBFBD><DBB8><EFBFBD>TextPro")]
public TextMeshProUGUI priceText;
[Header("<22><><EFBFBD>԰<EFBFBD><D4B0>µİ<C2B5>ť")]
public Button btn;
[Header("<22><><EFBFBD>°<EFBFBD>ť<EFBFBD><C5A5>ʾ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>")]
public GameObject prefab;
private int id;//item id
// Start is called before the first frame update
void Start()
{
btn.onClick.AddListener(()=> {
if (prefab.GetComponent<BaseUIPanel>()==null)
{
Debug.LogError("prefab.GetComponent<BaseUIPanel>()==null");
}
prefab.GetComponent<BaseUIPanel>().ShopPanel();
});
}
public void init(int id)
{
this.id = id;
}
void initShow(Sprite icon,string name,float price)
{
iconImage.sprite = icon;
nameText.text = name;
priceText.text = price.ToString();
}
}