_xiaofang/xiaofang/Assets/Script/UI/PanelUI/MaterialPanel.cs

54 lines
1.6 KiB
C#
Raw Normal View History

2024-11-29 09:47:47 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MaterialPanel : MonoBehaviour
{
[Header("<22><><EFBFBD><EFBFBD>")]
public GameObject materialPrefab; // <20><>Ʒ<EFBFBD><C6B7>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
public Transform materialContent; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Button addBtn; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
public Button subtractBtn; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
// <20><><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>Ʒ<EFBFBD><C6B7>
private List<MaterialItem> materialItems = new List<MaterialItem>();
// Start is called before the first frame update
void Start()
{
SetMaterialPrefab();
}
// Update is called once per frame
void Update()
{
}
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ƷԤ<C6B7><D4A4><EFBFBD><EFBFBD><E5A3AC>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>
public void SetMaterialPrefab()
{
for (int i = 0; i < 8; i++) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><38><EFBFBD><EFBFBD>Ʒ
{
GameObject item = Instantiate(materialPrefab, materialContent); // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>
MaterialItem materialItem = item.GetComponent<MaterialItem>(); // <20><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD>Ľű<C4BD>
materialItems.Add(materialItem); // <20><><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĻ<D0B5><C4BB><EFBFBD>
materialItem.materialName = "<22><>Ʒ" + (i + 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
materialItem.materialNameText.text = materialItem.materialName; // <20><><EFBFBD><EFBFBD>UI<55>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
}
}
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void SubmitMaterialData()
{
foreach (var materialItem in materialItems)
{
Debug.Log(materialItem.materialName + " <20><><EFBFBD><EFBFBD>: " + materialItem.GetMaterialNum());
}
}
}