using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine.UIElements; namespace DanieleMarotta.RiversongCodeShowcase { public class UIModel : IUIModel { public event EventHandler propertyChanged; public event Action Changed; protected void SetProperty(ref T field, T value, [CallerMemberName] string property = null) { if (EqualityComparer.Default.Equals(field, value)) return; field = value; NotifyPropertyChanged(property); } protected void NotifyPropertyChanged(string property = null) { propertyChanged?.Invoke(this, new BindablePropertyChangedEventArgs(property)); } public void NotifyChanged() { Changed?.Invoke(); } } }