How can I find a dropdown menu game object from a script?

Hello all, I’ve created a canvas with a dropdown menu in the editor, it’s there sitting in my Hierarchy window staring at me, but I cannot for the life of me figure out how to reference that from script.

I need to pass the value of the drop down menu to a function so I assume I need SOMETHING.value but I don’t know what that something is. I tried (Dropdown)GameObject.Find("myDropdown") and was told that i can’t convert from a game object to a dropdown :frowning:

I am not sure about your script. Still did you add “using UnityEngine.UI;” to the script. If not add that and check.
If this doesn’t solve your issue, please share your script, so that I will check and help you.

I was looking for this answer, I had exactly the same question. But now, how can I retrieve the value from the options instead of the value of the index? Meaning, if in the first option (index is 0) is “This” (string for example)


You would do it something like that:

 Dropdown uiDropdown = GameObject.Find("myDropdown").GetComponent<Dropdown>();

and then:

string chosenValue = uiDropdown.captionText.text;