using System; using UnityEngine; namespace DebuggingEssentials { [Serializable] public class GUIChangeBool { private static FastList applyList = new FastList(); [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(); } } }