namespace UIWidgets.Examples { using System; using System.ComponentModel; using UIWidgets; using UnityEngine; /// /// TreeViewSample continent item. /// [Serializable] public class TreeViewSampleItemContinent : ITreeViewSampleItem { [SerializeField] string name; /// /// Name. /// public string Name { get { return name; } set { if (name != value) { name = value; NotifyPropertyChanged("Name"); } } } [SerializeField] int countries; /// /// Countries. /// public int Countries { get { return countries; } set { if (countries != value) { countries = value; NotifyPropertyChanged("Countries"); } } } /// /// Initializes a new instance of the class. /// /// Name. /// Countries. public TreeViewSampleItemContinent(string itemName, int itemCountries = 0) { name = itemName; countries = itemCountries; } /// /// OnChange event. /// public event OnChange OnChange; /// /// Occurs when a property value changes. /// public event PropertyChangedEventHandler PropertyChanged; /// /// Notify property changed. /// /// Property name. protected void NotifyPropertyChanged(string propertyName) { var c_handlers = OnChange; if (c_handlers != null) { c_handlers(); } var handlers = PropertyChanged; if (handlers != null) { handlers(this, new PropertyChangedEventArgs(propertyName)); } } /// /// Display item data using specified component. /// /// Component. public void Display(TreeViewSampleComponent component) { component.Icon.sprite = null; component.Icon.color = Color.clear; component.TextAdapter.text = string.Format("{0} (Countries: {1})", Name, Countries.ToString()); } } }