GameObject DrawSelect(XsollaFormElement element) { GameObject newSelect = Instantiate(selectPrtefab) as GameObject; DropDownController controller = newSelect.GetComponent <DropDownController> (); newSelect.GetComponentInChildren <Text>().text = element.GetTitle(); List <Xsolla.XsollaFormElement.Option> options = element.GetOptions(); List <string> titles = new List <string> (options.Count); foreach (Xsolla.XsollaFormElement.Option o in options) { titles.Add(o.GetLabel()); } controller.SetParentForScroll(gameObject.transform.parent.parent); controller.OnItemSelected += (position, title) => { OnEndEdit(element.GetName(), options[position].GetValue()); }; controller.SetData(titles); // GameObject panel = newSelect.GetComponentInChildren<VerticalLayoutGroup> ().gameObject; // List<Xsolla.XsollaFormElement.Option> options = element.GetOptions (); // foreach (var option in options) // { // GameObject go = Instantiate(selectElementPrefab) as GameObject; // go.GetComponentInChildren<Text>().text = option.GetLabel(); // go.transform.SetParent(panel.transform); // } return(newSelect); }
public void SetCountries(string currentCountryIso, XsollaCountries countries) { _countries = countries; dropDownController.gameObject.SetActive(true); //Show countries dropdown dropDownController.SetParentForScroll(gameObject.transform.parent.parent.parent); dropDownController.OnItemSelected += (position, title) => { OnChangeCountry(position); }; dropDownController.SetData(countries.GetTitleList(), _countries.GetItemByKey(currentCountryIso).name); }