ProjectDDD/Assets/_DDD/_Scripts/GameUi/New/TabButtonUi.cs
2025-07-25 16:58:53 +09:00

48 lines
1.1 KiB
C#

using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace DDD
{
public enum RestaurantManagementSectionType
{
None = 0,
Menu,
Cookware,
Worker
}
public enum InventoryCategoryType
{
None = 0,
Food,
Drink,
Ingredient
}
public class TabButtonUi<T> : MonoBehaviour, ITabSelectable<T> where T : Enum
{
[field: SerializeField] public T TabType { get; private set; }
[SerializeField] private Button _button;
[SerializeField] private TextMeshProUGUI _label;
[SerializeField] private GameObject _content;
private Action<T> _onSelected;
public void Initialize(Action<T> onSelected)
{
_onSelected = onSelected;
_button.onClick.AddListener(() => _onSelected?.Invoke(TabType));
}
public void SetSelected(bool isSelected)
{
if (_content)
{
_content.SetActive(isSelected);
}
_button.interactable = !isSelected;
}
}
}