A game about forced loneliness, made by TACStudios
at master 75 lines 2.1 kB view raw
1#if UNITY_EDITOR 2using System; 3using System.Collections.Generic; 4 5namespace UnityEngine.InputSystem.Editor 6{ 7 internal class AdvancedDropdownItem : IComparable 8 { 9 internal readonly List<AdvancedDropdownItem> m_Children = new List<AdvancedDropdownItem>(); 10 11 public string name { get; set; } 12 public Texture2D icon { get; set; } 13 public int id { get; set; } 14 public bool enabled { get; set; } = true; 15 public int indent { get; set; } 16 17 internal int elementIndex { get; set; } = -1; 18 19 public IEnumerable<AdvancedDropdownItem> children => m_Children; 20 21 protected string m_SearchableName; 22 public virtual string searchableName => string.IsNullOrEmpty(m_SearchableName) ? name : m_SearchableName; 23 24 public void AddChild(AdvancedDropdownItem child) 25 { 26 m_Children.Add(child); 27 } 28 29 public int GetIndexOfChild(AdvancedDropdownItem child) 30 { 31 return m_Children.IndexOf(child); 32 } 33 34 static readonly AdvancedDropdownItem k_SeparatorItem = new SeparatorDropdownItem(); 35 36 public AdvancedDropdownItem(string name) 37 { 38 this.name = name; 39 id = name.GetHashCode(); 40 } 41 42 public virtual int CompareTo(object o) 43 { 44 return name.CompareTo((o as AdvancedDropdownItem).name); 45 } 46 47 public void AddSeparator(string label = null) 48 { 49 if (string.IsNullOrEmpty(label)) 50 AddChild(k_SeparatorItem); 51 else 52 AddChild(new SeparatorDropdownItem(label)); 53 } 54 55 internal bool IsSeparator() 56 { 57 return this is SeparatorDropdownItem; 58 } 59 60 public override string ToString() 61 { 62 return name; 63 } 64 65 private class SeparatorDropdownItem : AdvancedDropdownItem 66 { 67 public SeparatorDropdownItem(string label = "") 68 : base(label) 69 { 70 } 71 } 72 } 73} 74 75#endif // UNITY_EDITOR