Files
aibis-dream/Assets/Scripts/UI/Panel/DeveloperMode/DeveloperModeListRow.cs
T
2026-07-20 14:29:47 +08:00

42 lines
1.1 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)
{
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 = 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);
}
}
}