ProjectDDD/Packages/SLUnity/SLUI/SLUIWindowsList.cs
2025-07-08 19:46:31 +09:00

53 lines
1.1 KiB
C#

using System.Collections.Generic;
using UnityEngine;
namespace Superlazy.UI
{
[RequireComponent(typeof(SLUIButton))]
public class SLUIWindowsList : SLUIComponent
{
private static readonly List<SLUIButton> buttons = new List<SLUIButton>();
private SLUIButton button;
protected override void Validate()
{
button = GetComponent<SLUIButton>();
}
protected override void Init()
{
}
protected override void Enable()
{
if (button)
{
buttons.Add(button);
}
}
protected override void Disable()
{
if (button)
{
buttons.Remove(button);
}
}
public static bool OnEscape()
{
var count = buttons.Count;
if (count == 0)
{
return false;
}
var button = buttons[count - 1];
button.ButtonAction();
if (count == 1) return true;
buttons.RemoveAt(count - 1);
return true;
}
}
}