- Home /
ALWAYS SHOW DROPDOWN LIST
Hi,
I have a dropdown and I'm trying to always show the dropdown's list of elements. Currently I'm using the Show() method, but when I click on an option the list flicks. Is there any way to always show the list and when an option is clicked the dropdown doesn't flicker? This is the code I'm using at the moment:
[SerializeField] Dropdown targetDropdown;
[SerializeField] Transform objectsParent;
private Transform mainCamera;
private List<string> namesToDisplayOptions = new List<string>();
private void Awake()
{
mainCamera = Camera.main.transform;
SetObjectsToDisplay();
targetDropdown.onValueChanged.AddListener(delegate
{
ShowName(targetDropdown);
});
}
private void Update()
{
targetDropdown.Show();
}
private void SetObjectsToDisplay()
{
for (int i = 0; i < objectsParent.childCount; i++)
{
namesToDisplayOptions.Add(objectsParent.GetChild(i).name);
}
targetDropdown.AddOptions(namesToDisplayOptions);
}
private void ShowName(Dropdown target)
{
for (int i = 0; i < objectsParent.childCount; i++)
{
if (targetDropdown.captionText.text == objectsParent.GetChild(i).name.ToString())
{
print("OPTION " + objectsParent.GetChild(i).name + " CLICKED");
}
}
}
If you want the dropdown to be always visible, it's not a dropdown anymore, is it? If possible I would suggest creating a list of buttons or toggles, depending on your use-case
true but its more sleek to have a dropdown menu over a bunch of buttons. but maybe another option works similar to dropdown.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Canvas dropdown is buggy and i don't know how to solve it ;-; 0 Answers
Unable to reset dropdown value to -1 1 Answer
I need to create a drop DownList Like Structure in UI 0 Answers
Does anyone know how to make a Dropdown inside an element of another Dropdown? 0 Answers