Framwork/Assets/Scripts/Runtime/UI/Other/NotebookLineBar.cs

74 lines
2.0 KiB
C#
Raw Normal View History

2025-07-02 10:24:01 +08:00
using System;
using Data;
using UnityEngine;
2025-06-17 09:31:12 +08:00
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace Runtime.UI.Other
{
public class NotebookLineBar: MonoBehaviour
{
public GameObject notebookLine;// material
// public NormalThreedeeProduct notebook;
public Texture[] colorTexs;
public Sprite[] sprites;
2025-07-02 10:24:01 +08:00
public string[] inventoryLineName;
2025-06-17 09:31:12 +08:00
public Button buttonPfb;
public Transform holder;
2025-07-02 10:24:01 +08:00
public Action<Texture> OnClickAction;
2025-06-17 09:31:12 +08:00
void OnEnable()
{
Init();
}
private void Init()
{
foreach(Transform t in holder)
{
Destroy(t.gameObject);
}
for (int i = 0; i < colorTexs.Length; i++)
{
var spawn = Instantiate(buttonPfb, holder);
spawn.image.sprite = sprites[i];
var tex = colorTexs[i];
int current = i;
2025-07-02 10:24:01 +08:00
int count = 0;
var datas = ExcelManager.Inventory.Datas.InventoryList;
var lineName = inventoryLineName[i];
foreach (var data in datas)
{
if (data.Lint == lineName)
{
count += data.Count;
}
}
if (count <= 0)
{
spawn.transform.GetChild(0).gameObject.SetActive(true);
continue;
}
2025-06-17 09:31:12 +08:00
// bool isHave = notebook.CheckLayoutQuantity(i);
// if (!isHave)
// {
// spawn.transform.GetChild(0).gameObject.SetActive(true);
// continue;
// }
//
2025-07-02 10:24:01 +08:00
spawn.onClick.AddListener(() =>
{
OnClickAction?.Invoke(tex);
// notebook.ChangeLayout(tex, current);
});
2025-06-17 09:31:12 +08:00
}
}
}
}