Question by
belove6893 · May 10, 2017 at 07:02 AM ·
uidropdownreuse
Reuseable Dropdown
Well...I create a dropdown ui to let user choose the value that he want and save the value for further use. First try is a success, but when i click the second time to save second value, the dropdown didn't drop down the list for me to choose the value. Is something going wrong in my code? using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class VDropDown : MonoBehaviour {
GameObject canvas;
public Dropdown dropdown;
GameObject button;
GameObject dd;
X scriptto;
Y scripttoy;
Z scripttoz;
public Text code;
int i = 0;
// Use this for initialization
void Start()
{
canvas = GameObject.FindWithTag("maincanvas");
dd = GameObject.FindWithTag("varabledropdown");
button = GameObject.FindWithTag("varable");
scriptto = canvas.GetComponent<X>();
scripttoy = canvas.GetComponent<Y>();
scripttoz = canvas.GetComponent<Z>();
//dropdown.SetActive(false);
}
public void onTimeChoose()
{
int chosenInt = GameObject.FindWithTag("varabledropdown").GetComponent<Dropdown>().value;
if (i == 0)
{
scriptto.setVar(chosenInt);
i++;
}
else if (i == 1)
{
scripttoy.setVar(chosenInt);
i++;
}
else if (i == 2)
{
scripttoz.setVar(chosenInt);
i++;
}
dropdown.RefreshShownValue();
dd.SetActive(false);
button.SetActive(true);
code.text += chosenInt + ";\n";
}
}
Comment
Your answer
Follow this Question
Related Questions
How do you access the text value of the Dropdown UI? 6 Answers
How to change the Font Asset from a Dropdown List item? 1 Answer
Unity dropdown automatically scrolling up 0 Answers
UI Dropdown problem. 1 Answer
Trying to list names from text files in dropdown options.,Trying to list info from txt files. 0 Answers