Files
aibis-dream/Assets/Scripts/UI/Panel/DeveloperMode/DeveloperModeListRow.cs
T
2026-07-24 13:16:03 +08:00

50 lines
1.3 KiB
C#

using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace AibisDream.UI
{
public sealed class DeveloperModeListRow : MonoBehaviour
{
[SerializeField] private Button button;
[SerializeField] private TMP_Text label;
[SerializeField] private Image background;
public void Bind(
string text,
Action clicked,
bool interactable,
Color color,
bool isError = false,
bool isSelected = false)
{
label.text = text ?? string.Empty;
label.color = color;
button.onClick.RemoveAllListeners();
if (clicked != null)
{
button.onClick.AddListener(() => clicked());
}
button.interactable = interactable;
if (background != null)
{
background.color = isSelected
? new Color(0.06f, 0.28f, 0.34f, 0.96f)
: isError
? new Color(0.20f, 0.07f, 0.07f, 0.92f)
: new Color(0.08f, 0.12f, 0.16f, 0.92f);
}
gameObject.SetActive(true);
}
public void Hide()
{
button.onClick.RemoveAllListeners();
gameObject.SetActive(false);
}
}
}