74 lines
2.0 KiB
C#
74 lines
2.0 KiB
C#
using System;
|
|
using Data;
|
|
using UnityEngine;
|
|
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;
|
|
public string[] inventoryLineName;
|
|
public Button buttonPfb;
|
|
public Transform holder;
|
|
public Action<Texture> OnClickAction;
|
|
|
|
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;
|
|
|
|
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;
|
|
}
|
|
|
|
// bool isHave = notebook.CheckLayoutQuantity(i);
|
|
// if (!isHave)
|
|
// {
|
|
// spawn.transform.GetChild(0).gameObject.SetActive(true);
|
|
// continue;
|
|
// }
|
|
//
|
|
spawn.onClick.AddListener(() =>
|
|
{
|
|
OnClickAction?.Invoke(tex);
|
|
// notebook.ChangeLayout(tex, current);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |