using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BITKit { public interface IOptional { bool Allow { get; } object Value { get; } } public interface IOptional { bool Allow { get; } T Value { get; } } [System.Serializable] public record Optional : IOptional { #if UNITY [UnityEngine.SerializeField] bool allow; [UnityEngine.SerializeField] T value; #else bool allow; T value; #endif public bool Allow { get => allow; set => allow = value;} public T Value { get => value; set => this.value = value; } public void SetValueThenAllow(T newValue) => value = newValue; public void Clear() { Allow = false; value = default; } } }