//get button components from panel void Awake() { Assert.IsNotNull(player_1_selection_panel, "player_1_selection_panel is null in MainMenuScripts.cs"); Assert.IsNotNull(player_2_selection_panel, "player_2_selection_panel is null in MainMenuScripts.cs"); Assert.IsNotNull(player_3_selection_panel, "player_3_selection_panel is null in MainMenuScripts.cs"); Assert.IsNotNull(player_4_selection_panel, "player_4_selection_panel is null in MainMenuScripts.cs"); player_1_dropdown = player_1_selection_panel.transform.Find("ControlDropdown").GetComponent <Dropdown>(); color_1_dropdown = player_1_selection_panel.GetComponentInChildren <ColorDropdown>(); player_1_tag = player_1_selection_panel.GetComponentInChildren <PlayerTagIndicator>(); player_2_dropdown = player_2_selection_panel.transform.Find("ControlDropdown").GetComponent <Dropdown>(); color_2_dropdown = player_2_selection_panel.GetComponentInChildren <ColorDropdown>(); player_2_tag = player_2_selection_panel.GetComponentInChildren <PlayerTagIndicator>(); player_3_dropdown = player_3_selection_panel.transform.Find("ControlDropdown").GetComponent <Dropdown>(); color_3_dropdown = player_3_selection_panel.GetComponentInChildren <ColorDropdown>(); player_3_tag = player_3_selection_panel.GetComponentInChildren <PlayerTagIndicator>(); player_4_dropdown = player_4_selection_panel.transform.Find("ControlDropdown").GetComponent <Dropdown>(); color_4_dropdown = player_4_selection_panel.GetComponentInChildren <ColorDropdown>(); player_4_tag = player_4_selection_panel.GetComponentInChildren <PlayerTagIndicator>(); Assert.IsNotNull(player_1_dropdown, "player_1_dropdown is null in MainMenuScripts.cs"); Assert.IsNotNull(player_2_dropdown, "player_2_dropdown is null in MainMenuScripts.cs"); Assert.IsNotNull(player_3_dropdown, "player_3_dropdown is null in MainMenuScripts.cs"); Assert.IsNotNull(player_4_dropdown, "player_4_dropdown is null in MainMenuScripts.cs"); }
void DropdownValueChanged(ColorDropdown change) { if (change.value < curOptions.Count) { Debug.LogFormat("New val :{0}", change.value); EventRestAPI.Instance.SwitchToEvent(curOptions[change.value]); } }
public void UpdateList() { if (EventRestAPI.Instance == null) { Debug.Log("NULL Instance"); managed.interactable = false; return; } curOptions.Clear(); List <ColorDropdown.OptionData> lst = new List <ColorDropdown.OptionData>(); if (EventRestAPI.settings == null) { Debug.Log("Nyanya NULL settings"); return; } if (EventRestAPI.settings.eventData == null) { Debug.Log("Nyanya NULL evdata"); return; } foreach (SavedEventData edat in EventRestAPI.settings.eventData) { ColorDropdown.OptionData dopt = new ColorDropdown.OptionData(); //Debug.Log("Nyanya"+JsonUtility.ToJson(edat.description)); dopt.image = null; if (edat.description.humName != null) { dopt.text = string.Format("Ev. {0} : {1} ({2}), {3}TeV", edat.description.humName, edat.description.baseDesc, edat.description.eventDate, edat.description.energy); } else { dopt.text = string.Format("Ev. {0}/{1} : {2} ({3}), {4}TeV", edat.description.run, edat.description.evn, edat.description.baseDesc, edat.description.eventDate, edat.description.energy); } dopt.sortKey = edat.getSortLabel(); lst.Add(dopt); curOptions.Add(edat.description); } lst.Sort((x, y) => - x.sortKey.CompareTo(y.sortKey)); //Debug.Log("Nyanya options"); //Debug.Log("DropboxUpdate"); if (managed == null) { managed = gameObject.GetComponent <ColorDropdown>(); } managed.options = lst; if (lst.Count > 0) { managed.interactable = true; DropdownValueChanged(managed); } //managed.ClearOptions(); //managed.AddOptions(lst); }
// Start is called before the first frame update void Start() { managed = gameObject.GetComponent <ColorDropdown>(); if (managed == null) { Destroy(this); return; } managed.onValueChanged.AddListener(delegate { DropdownValueChanged(managed); }); //Dropdown.OptionData opt; //opt.image = null; StartCoroutine(waitAndDefault()); }
/// <summary> /// Populates the dropdown UI menu with a list of strings /// </summary> void PopulateColorList() { ColorDropdown.AddOptions(colorNames); }