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

57 lines
1.9 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>();
public JSONReader jsonReader1;
2024-12-25 17:07:27 +08:00
public WarningPopPanel warningPopPanel1;
2024-11-29 09:47:47 +08:00
// 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()
{
foreach (var materialData in jsonReader1.matialDictionary)
2024-11-29 09:47:47 +08:00
{
GameObject item = GameObject.Instantiate<GameObject>(materialPrefab, materialContent);
MaterialItem materialItem = item.GetComponent<MaterialItem>();
materialItem.materialNameText.text = materialData.Value.Note;
2024-12-07 16:18:15 +08:00
materialItem.materialId = materialData.Key.ToString();
materialItems.Add(materialItem);
}
2024-11-29 09:47:47 +08:00
}
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void SubmitMaterialData()
{
2024-12-12 15:21:07 +08:00
createTemplateInfo.Instance.auth_CreateTemplate.materialList = new List<MaterialList>();
2024-11-29 09:47:47 +08:00
foreach (var materialItem in materialItems)
{
2024-12-07 16:18:15 +08:00
MaterialList materialList = new MaterialList();
materialList.materialId = materialItem.materialId;
materialList.num = materialItem.materialNum;
createTemplateInfo.Instance.auth_CreateTemplate.materialList.Add(materialList);
2024-11-29 09:47:47 +08:00
}
2024-12-25 17:07:27 +08:00
warningPopPanel1.OpenPanel("<22><EFBFBD>ɹ<EFBFBD>");
2024-11-29 09:47:47 +08:00
}
}