private void Start() { var select = new ComboBoxItem("Select"); comboBox.AddItems(select); StartCoroutine(RefreshMatches()); }
private void Start() { List <ComboBoxItem> items = new List <ComboBoxItem>(); ComboBoxItem selectItem = new ComboBoxItem("Select"); items.Add(selectItem); comboBox.AddItems(items.ToArray()); Action <bool, Dictionary <string, string>, string> callback = (success, decks, errorMessage) => { if (success) { List <ComboBoxItem> newItems = new List <ComboBoxItem>(); foreach (KeyValuePair <string, string> entry in decks) { Debug.Log("found deck: " + entry.Key); ComboBoxItem newItem = new ComboBoxItem(entry.Value); newItem.OnSelect += () => { Debug.Log("selected deck: " + entry.Value); errorLabel.text = ""; GameManager.Instance.CurrentDeckId = entry.Value; Application.LoadLevel("OpponentSelection"); }; newItems.Add(newItem); } // comboBox.ClearItems(); comboBox.AddItems(newItems.ToArray()); } else { Debug.Log("WARN!!! didn't get decks"); errorLabel.text = "didn't get decks"; } }; StartCoroutine(Platform.Instance.ListDecks(GameManager.Instance.CurrentPlayerId, callback)); List <ComboBoxItem> gDriveItems = new List <ComboBoxItem>(); foreach (KeyValuePair <string, Deck> kvp in GameManager.Instance.DeckData) { ComboBoxItem gDriveItem = new ComboBoxItem(kvp.Key); gDriveItem.OnSelect += () => { errorLabel.text = ""; GameManager.Instance.CurrentDeckId = kvp.Key; Application.LoadLevel("OpponentSelection"); }; gDriveItems.Add(gDriveItem); } comboBox.AddItems(gDriveItems.ToArray()); }
// Use this for initialization void Start() { objective = Objective.GetInstance(); dropdown.AddItems(objective.GetIndividualObjectives().ToArray()); dropdown.HideFirstItem = false; dropdown.OnSelectionChanged += (int index) => { updateInput(index); }; objectiveControllerInstance = this; }
// Use this for initialization void Start() { teamDropdown.ClearItems(); teamDropdown.AddItems(getNameArray(Team.GetTeams())); if (Team.GetTeams().Count > 0) { updateUI(Team.GetTeams() [0]); } teamDropdown.OnSelectionChanged += (int index) => { updateUI(Team.GetTeams()[index]); }; }
private void TeamDropdownSetup() { if (Team.GetTeams() == null || Team.GetTeams().Count <= 1) { Invoke("TeamDropdownSetup", .1f); return; } MouseCoordinates.SetActive(true); TeamDropdown = TeamDropdownObject.GetComponent <ComboBox> (); int TeamNum = Team.GetTeams().Count - 1; string[] TeamNames = new string[TeamNum]; for (int i = 0; i < TeamNum; i++) { TeamNames[i] = Team.GetTeam(i + 1).GetTeamName(); } TeamDropdown.ClearItems(); TeamDropdown.AddItems(TeamNames); SubToggle = SubToggleObject.GetComponent <Toggle> (); //SubDropdownSetup (); TeamDropdown.OnSelectionChanged += (int index) => { TeamID = index + 1; if (SubToggle.isOn) { SubDropdownSetup(); } }; LanguageDropdown.OnSelectionChanged += (int index) => { UpdateLanguage(index); }; }
public void SubDropdownSetup() { UniversalUIObject = GameObject.Find("UniversalUIObject"); SubDropdown = SubDropdownObject.GetComponent <ComboBox> (); GameObject[] SubSurfaceUnits = GameObject.FindGameObjectsWithTag("Subsurface"); TeamSubs = new List <GameObject> (); for (int i = 0; i < SubSurfaceUnits.Length; i++) { if (SubSurfaceUnits[i].GetComponent <IdentityController>().TeamNumber == TeamID) { TeamSubs.Add(SubSurfaceUnits[i]); } } string[] SubNames = new string[TeamSubs.Count]; for (int i = 0; i < TeamSubs.Count; i++) { SubNames[i] = TeamSubs[i].GetComponent <IdentityController>().GetName(); } SubDropdown.ClearItems(); SubDropdown.AddItems(SubNames); SelectedSub = TeamSubs[0]; SubDropdown.OnSelectionChanged += (int index) => { SelectedSub = TeamSubs[index]; }; }
public void RefreshTerrainList() { Debug("Refreshing interface terrain list."); terrainSelect.ClearItems(); terrainSelect.AddItems(new string[] { "" }); LocalizedItem[] itemList = new LocalizedItem[Terrain.Names.Length]; for (int i = 0; i < Terrain.Names.Length; i++) { itemList[i] = new LocalizedItem("UI_Admin", "Text_Map_" + Terrain.Names[i]); } terrainSelect.AddItems(itemList); UpdateSelection(); }
private void RefreshComboBox() { Object[] mazeObjs = Resources.LoadAll("Mazes/"); foreach (Object maze in mazeObjs) { comboBox.AddItems(maze.name); } }
private void LoadSaveOptions() { Object[] mazeObjs = Resources.LoadAll("Mazes/"); foreach (Object maze in mazeObjs) { comboBox.AddItems(maze.name); } }
public static void RefreshTeams(ComboBox dropdown) { int selectedIndex = dropdown.SelectedIndex; dropdown.ClearItems(); dropdown.AddItems(getNameArray(Team.GetTeams())); dropdown.SelectedIndex = selectedIndex; //Debug.Log("Team combobox refreshed!"); }
public void SetAirLabels() { if (null == units) { units = GameObject.Find("UnitComboBox").GetComponent <ComboBox> (); } if (null == units) { return; } units.gameObject.SetActive(true); nameList = Factory.GetAirDAO().GetLocalizedNames(); units.ClearItems(); units.AddItems(nameList.ToArray()); units.SelectedIndex = 0; setSelectedToggle(AIR); RefreshUI(); }
public void Start() { List <ComboBoxItem> items = new List <ComboBoxItem>(); ComboBoxItem selectItem = new ComboBoxItem("Select"); selectItem.OnSelect += () => { Debug.Log("info: click select. no-op."); }; items.Add(selectItem); ComboBoxItem timedItem = new ComboBoxItem("Timed"); timedItem.OnSelect += () => { errorLabel.text = "Invalid selection."; }; items.Add(timedItem); ComboBoxItem untimedItem = new ComboBoxItem("Untimed"); untimedItem.OnSelect += () => { GameManager.Instance.CurrentTimeFormat = "Untimed"; MatchCriteria criteria = new MatchCriteria(GameManager.Instance.CurrentDeckId, GameManager.Instance.CurrentOpponentType, GameManager.Instance.CurrentTimeFormat); Debug.Log("RandomOnlineTimeFormatDropdown:SelectTime() - CurrentPlayerID: " + GameManager.Instance.CurrentPlayerId); Debug.Log("RandomOnlineTimeFormatDropdown:SelectTime() - match criteria: " + criteria.ToString()); GameManager.Instance.QuickMatchCriteria = criteria; Action <bool, TurnBasedMatch, string> callback = (success, m, errors) => { if (success) { //Debug.Log("ArenaStartMatch:StartMatch success: " + m.Status); GameManager.Instance.QuickMatchCriteria = criteria; Application.LoadLevel("Arena"); } else { Debug.Log("ArenaStarMatch:StartMatch WARN!!!! failed to create match"); } }; StartCoroutine(Platform.Instance.CreateMatch(criteria, callback)); }; items.Add(untimedItem); comboBox.ClearItems(); comboBox.AddItems(items.ToArray()); }
private void Start() { var itemMakeBig = new ComboBoxItem("Make me big!"); var itemMakeNormal = new ComboBoxItem("Normal", image, true); var itemMakeSmall = new ComboBoxItem("Make me small!"); itemMakeBig.OnSelect += () => { comboBox.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 180); comboBox.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40); comboBox.UpdateGraphics(); itemMakeBig.Caption = "Big"; itemMakeBig.IsDisabled = true; itemMakeNormal.Caption = "Make me normal!"; itemMakeNormal.IsDisabled = false; itemMakeSmall.Caption = "Make me small!"; itemMakeSmall.IsDisabled = false; }; itemMakeNormal.OnSelect += () => { comboBox.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 160); comboBox.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 30); comboBox.UpdateGraphics(); itemMakeBig.Caption = "Make me big!"; itemMakeBig.IsDisabled = false; itemMakeNormal.Caption = "Normal"; itemMakeNormal.IsDisabled = true; itemMakeSmall.Caption = "Make me small!"; itemMakeSmall.IsDisabled = false; }; itemMakeSmall.OnSelect += () => { comboBox.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 160); comboBox.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 20); comboBox.UpdateGraphics(); itemMakeBig.Caption = "Make me big!"; itemMakeBig.IsDisabled = false; itemMakeNormal.Caption = "Make me normal!"; itemMakeNormal.IsDisabled = false; itemMakeSmall.Caption = "Small"; itemMakeSmall.IsDisabled = true; }; comboBox.AddItems(itemMakeBig, itemMakeNormal, itemMakeSmall); comboBox.SelectedIndex = 1; comboBox.OnSelectionChanged += (int index) => { Camera.main.backgroundColor = new Color32((byte)Random.Range(0, 256), (byte)Random.Range(0, 256), (byte)Random.Range(0, 256), 255); }; }
public void Awake() { Transform HealthLabel = transform.Find("HealthLabel"); HMInput = HealthLabel.FindChild("HMInput").GetComponent <InputField>(); NDInput = HealthLabel.FindChild("NDInput").GetComponent <InputField>(); NWInput = HealthLabel.FindChild("NWInput").GetComponent <InputField>(); NMInput = HealthLabel.FindChild("NMInput").GetComponent <InputField>(); HMInput.text = GlobalSettings.GetHealthThresholdForHalfMovement().ToString(); NDInput.text = GlobalSettings.GetHealthThresholdForNoDetectors().ToString(); NWInput.text = GlobalSettings.GetHealthThresholdForNoWeapons().ToString(); NMInput.text = GlobalSettings.GetHealthThresholdForNoMovement().ToString(); LanguageManager langManager = GameObject.FindObjectOfType <LanguageManager> (); localDropdown.OnSelectionChanged += (int index) => { if (index == EN) { langManager.english(); } else if (index == SP) { langManager.spanish(); } else if (index == FR) { langManager.french(); } else if (index == IT) { langManager.italian(); } else if (index == JP) { langManager.japanese(); } }; LocalizedItem[] weathers = new LocalizedItem[Weather.GetWeathers().Count]; foreach (int i in Weather.GetWeathers().Keys) { weathers[i] = new LocalizedItem("UI_Admin", "Text_WeatherType_" + Weather.GetWeathers()[i].WeatherType); } weatherDropdown.AddItems(weathers); }
public void FillWeaponDropdown(GameObject unit) { WepDropdown.ClearItems(); AttackController uat = unit.GetComponent <AttackController>(); LocalizedItem[] stringlist = new LocalizedItem[uat.GetWeapons().Count]; int listidx = 0; foreach (string key in uat.GetWeapons().Keys) { int i = key.LastIndexOf("-"); stringlist[listidx++] = new LocalizedItem(unit.tag.Equals("Marine") ? "Marine_Weapon" : "Weapons", key.Substring(0, i), key.Substring(i)); } WepDropdown.AddItems(stringlist); WepDropdown.SelectedIndex = 0; if (stringlist.Length > 0) { FillWeaponFields(stringlist [WepDropdown.SelectedIndex].ToString()); } }
// Use this for initialization void Start() { //Fill team dropdown TeamDropdown.ClearItems(); TeamDropdown.AddItems(teamListToStringArray(Team.GetTeams())); //Get instances of toggles SurfaceToggle = transform.FindChild("SurfaceToggle").gameObject.GetComponent <Toggle> (); AirToggle = transform.FindChild("AirToggle").gameObject.GetComponent <Toggle> (); SubSurfaceToggle = transform.FindChild("SubSurfaceToggle").gameObject.GetComponent <Toggle> (); MarineToggle = transform.FindChild("MarineToggle").gameObject.GetComponent <Toggle> (); Factory = DAOFactory.GetFactory(); nameList = new List <LocalizedItem> (); //Get instances of Unit info labels RangeValue = GameObject.Find("RangeValue"); HealthValue = GameObject.Find("HealthValue"); WeaponCountValue = GameObject.Find("WeaponCountValue"); UnitName = transform.parent.Find("UnitInfo").Find("UnitName").gameObject; AirSensorValue = GameObject.Find("AirSensorValue"); SurfaceSensorValue = GameObject.Find("SurfaceSensorValue"); SubSensorValue = GameObject.Find("SubSensorValue"); ContainerValue = GameObject.Find("ContainerValue"); ContainerLabel = GameObject.Find("ContainerLabel"); units = GameObject.Find("UnitComboBox").GetComponent <ComboBox> (); units.gameObject.SetActive(false); transform.parent.Find("UnitInfo").gameObject.SetActive(false); objectFactory = new ObjectFactory(); units.OnSelectionChanged += (int index) => { updateUnitInfo(nameList [index].label); }; }
public void TestComboBoxAddItemsException() { ComboBox box = new ComboBox("box"); Assert.AreEqual(box, box.AddItems(new object[] { "item1", "item2" })); }
// Update is called once per frame void Update() { if (GameObject.Find("Canvas") != null) { GameObject.Destroy(GameObject.Find("Canvas")); GameObject.Destroy(GameObject.Find("UniversalUIObject")); } var tempNames = ClientHostPull.HostInstance.names; if (tempNames != null && tempNames.Length != 0) { bool refresh = false; if (tempNames.Length == names.Length) { var toTest = new List <string>(tempNames); foreach (string stringToCompare in names) { if (!toTest.Contains(stringToCompare)) { refresh = true; break; } } } else { refresh = true; } if (refresh) { names = tempNames; hostSelector2.ClearItems(); hostSelector2.AddItems(names); hostSelector.ClearItems(); hostSelector.AddItems(names); } } if (connecting) { if (connectionCode == 1) { switch (code) { case ADMIN_CODE: Application.LoadLevel(ADMIN_SCENE_NAME); break; case USER_CODE: Application.LoadLevel(USER_SCENE_NAME); //Application.LoadLevel ("UserSceneTest"); break; case SPECTATOR_CODE: Application.LoadLevel(SPECTATOR_SCENE_NAME); break; } connecting = false; } else if (connectionCode == 0) { //display failed to connect connecting = false; } } }