ProjectDDD/Packages/SLUnity/SLUI/SLUIColorSelect.cs
2025-06-25 11:33:17 +09:00

63 lines
1.5 KiB (Stored with Git LFS)
C#

using System;
using UnityEngine;
using UnityEngine.UI;
namespace Superlazy.UI
{
public class SLUIColorSelect : SLUIComponent
{
public SLValueComparison[] comparisons;
public Color[] colors;
[NonSerialized]
public Graphic graphic;
protected override void Validate()
{
graphic = GetComponent<Graphic>();
}
protected override void Init()
{
}
protected override void Enable()
{
foreach (var c in comparisons)
{
c.OnEnable(bindParent.BindPath, OnChange);
}
}
protected override void Disable()
{
foreach (var c in comparisons)
{
c.OnDisable();
}
}
private void OnChange()
{
if (bindParent.Active == false) return;
var sessionRoot = SLGame.SessionGet(bindParent.BindPath);
if (sessionRoot == false) return; // TEMP: 세션루트가 삭제되었지만, 삭제되되기전 코루틴 처리가 있을 수 있음
var idx = 0;
foreach (var c in comparisons)
{
if (c.Result)
{
graphic.color = colors[idx];
return;
}
idx++;
}
if (colors.Length > idx)
{
graphic.color = colors[idx];
}
}
}
}