Files
2026-03-04 09:37:33 +08:00

82 lines
1.1 KiB
C#

using System;
using UnityEngine;
namespace DebuggingEssentials
{
[Serializable]
public class GUIChangeBool
{
private static FastList<GUIChangeBool> applyList = new FastList<GUIChangeBool>();
[SerializeField]
private bool value;
[NonSerialized]
private bool newValue;
[NonSerialized]
private bool hasChanged;
public bool Value
{
get
{
return value;
}
set
{
if (newValue != value || !hasChanged)
{
newValue = value;
if (!hasChanged)
{
applyList.Add(this);
hasChanged = true;
}
}
}
}
public bool RealValue
{
get
{
if (hasChanged)
{
return newValue;
}
return value;
}
}
public GUIChangeBool()
{
}
public GUIChangeBool(bool value)
{
this.value = (newValue = value);
}
public static void ResetStatic()
{
applyList.Clear();
}
public void Update()
{
value = newValue;
hasChanged = false;
}
public static void ApplyUpdates()
{
for (int i = 0; i < applyList.Count; i++)
{
applyList.items[i].Update();
}
applyList.Clear();
}
}
}