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

56 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;
2024-11-27 15:27:50 +08:00
2024-11-25 14:35:28 +08:00
private int id;//item id
// Start is called before the first frame update
void Start()
{
btn.onClick.AddListener(()=> {
2024-11-27 15:27:50 +08:00
GameObject.Instantiate(prefab,GameObject.Find("Canvas").transform);
2024-11-25 14:35:28 +08:00
});
}
public void init(int id)
{
this.id = id;
}
2024-11-27 23:39:41 +08:00
public void initShow(int id, Sprite icon, string name, string price)
2024-11-27 22:22:41 +08:00
{
this.id = id;
2024-11-25 14:35:28 +08:00
iconImage.sprite = icon;
nameText.text = name;
2024-11-27 23:39:41 +08:00
priceText.text = price;
2024-11-27 22:22:41 +08:00
}
2024-11-25 14:35:28 +08:00
2024-11-27 23:39:41 +08:00
public void initShow(int id, string name, string price)
2024-11-27 22:22:41 +08:00
{
this.id = id;
nameText.text = name;
2024-11-27 23:39:41 +08:00
priceText.text = price;
2024-11-27 22:22:41 +08:00
}
2024-11-25 14:35:28 +08:00
}