namespace UIWidgets.Examples { using System; using System.ComponentModel; using UIWidgets; using UnityEngine; /// /// TreeViewSampleItemCountry. /// Sample class to display country data. /// [Serializable] public class TreeViewSampleItemCountry : ITreeViewSampleItem { [SerializeField] Sprite icon; /// /// Icon. /// public Sprite Icon { get { return icon; } set { if (icon != value) { icon = value; NotifyPropertyChanged("Icon"); } } } [SerializeField] string name; /// /// Name. /// public string Name { get { return name; } set { if (name != value) { name = value; NotifyPropertyChanged("Name"); } } } /// /// Initializes a new instance of the class. /// /// Name. /// Icon. public TreeViewSampleItemCountry(string itemName, Sprite itemIcon = null) { name = itemName; icon = itemIcon; } /// /// 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 data with specified component. /// /// Component to display item. public void Display(TreeViewSampleComponent component) { component.Icon.sprite = Icon; component.TextAdapter.text = Name; if (component.SetNativeSize) { component.Icon.SetNativeSize(); } component.Icon.color = (component.Icon.sprite == null) ? Color.clear : Color.white; } } }