void OnListItemUnselected(ComboBox.ComboItem unselectedItem) { if (selectedHost == (HostData)unselectedItem.value) { selectedHost = null; } }
// Use this for initialization void Start() { cb = new ComboBox(); style = new GUIStyle(); foreach(Transform child in this.transform) { ComboBox.ComboItem childItem = new ComboBox.ComboItem(child.name, child); childItem.OnMarkedAction += SelectItem; childItem.OnUnMarkedAction += DeselectItem; cb.AddItem(childItem); } }
// Use this for initialization void Start() { cb = new ComboBox(); style = new GUIStyle(); foreach (Transform child in this.transform) { ComboBox.ComboItem childItem = new ComboBox.ComboItem(child.name, child); childItem.OnMarkedAction += SelectItem; childItem.OnUnMarkedAction += DeselectItem; cb.AddItem(childItem); } }
// Update is called once per frame void Update() { //Check for an updated list, and refresh the items in the list when we have one. if (hostsUpdated) { hostsUpdated = false; hostList.Clear(); foreach (HostData hostdata in hosts) { ComboBox.ComboItem item = hostList.AddItem(hostdata.gameName, hostdata, OnListItemSelected, OnListItemUnselected); //Maintain our selected host, even through a wipe and refresh //Would want to implement a more robust comparison between selectedHost and hostdata if (selectedHost != null && hostdata.gameName == selectedHost.gameName && hostdata.ip[0].Equals(selectedHost.ip[0])) { item.Mark(); selectedHost = hostdata; } } } }
void OnLayerUnselected(ComboBox.ComboItem item) { layerMask = layerMask & ~(1 << (int)item.value); }
void OnListItemSelected(ComboBox.ComboItem selectedItem) { selectedHost = (HostData)selectedItem.value; }
void DeselectItem(ComboBox.ComboItem item) { //Move the item down so we can see it's not selected ((Transform)item.value).Translate(0, -1, 0); }
void SelectItem(ComboBox.ComboItem item) { //Move the item up so we can see it's selected ((Transform)item.value).Translate(0, 1, 0); }