Showing what a user has chosen from a dropdown menu

First of all, thank you for your help:

I have two things: an InputField and a dropdown menu.

I have an empty text asset which shows the text written in the inputfield with the following code: 56867-inputfield.png

The thing that I try to accomplish is to get the same result from a dropdown menu: the choice to be displayed in another empty text asset.

I simply tried to change the userName and “UserName” to userContinent and “UserContinent” due to the fact that my empty text asset is called UserContinent but unfortunately it did not work.

I personally think the issue comes from the string variable because it is not a string in the dropdown menu but something else that I cannot seem to find.

Any help will be appreciated

Example project (Unity 5.2.2f1)

So, you can hook up to events from the Dropdown component like you did with InputField. However, the Dropdown event only gives you a single index. It’s useless without a reference to the Dropdown. I solved this by adding a custom event trigger to the Dropdown that forwards both the Dropdown that sent the event and the selected index.

If you use that DropdownTrigger that I sent, you only need to add one more function to your existing code:

    public void userNameShow(Dropdown dropdown, int index)
    {
        userName.text = dropdown.options[index].text;
    }

And then you need to bind the event from DropdownTrigger to your userNameShow function. Look at this illustration.

Make sure that you add a On Value Changed handler on Dropdown Trigger. Set the receiver to your game object that has your script, and select the function from the Dynamic list (pink).

If you want to know how it gets to execute your code and set the text, read on. Otherwise you can ignore the rest.

EventSystem sends (red) input to Dropdown. Dropdown sends On Value Changed event to Dropdown Trigger. Dropdown Trigger sends (green) On Value Changed event to your userNameShow function. Your function sets the text of UserName.