63 lines
1.5 KiB
C#
63 lines
1.5 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class MaterialItem : MonoBehaviour
|
|||
|
{
|
|||
|
[Header("<22><><EFBFBD><EFBFBD>")]
|
|||
|
public Text materialText; // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|||
|
public Image materialImage; // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
public Text materialNameText; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|||
|
public Image hightImage; // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
|
|||
|
[Header("<22><><EFBFBD><EFBFBD>")]
|
|||
|
public int materialNum = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public string materialName; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// Start is called before the first frame update
|
|||
|
void Start()
|
|||
|
{
|
|||
|
materialText.text = materialNum.ToString(); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|||
|
UpdateHighlightImage(); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public void AddNum()
|
|||
|
{
|
|||
|
materialNum++;
|
|||
|
materialText.text = materialNum.ToString();
|
|||
|
UpdateHighlightImage(); // <20><><EFBFBD>¸<EFBFBD><C2B8><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public void SubtractNum()
|
|||
|
{
|
|||
|
if (materialNum > 0)
|
|||
|
{
|
|||
|
materialNum--;
|
|||
|
materialText.text = materialNum.ToString();
|
|||
|
UpdateHighlightImage(); // <20><><EFBFBD>¸<EFBFBD><C2B8><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD>¸<EFBFBD><C2B8><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ״̬
|
|||
|
private void UpdateHighlightImage()
|
|||
|
{
|
|||
|
if (materialNum > 0)
|
|||
|
{
|
|||
|
hightImage.gameObject.SetActive(true); // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
hightImage.gameObject.SetActive(false); // <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public int GetMaterialNum()
|
|||
|
{
|
|||
|
return materialNum;
|
|||
|
}
|
|||
|
}
|