How To Create a Drop Down Menu – And Get Selected Value [Beginner Tutorial - Unity 2019]

preview_player
Показать описание
How to create a dropdown in Unity! In this tutorial we build a simple dropdown menu and get the selected value.

····················································································

♥ Subscribe to Oxmond Tutorials. New tutorials every day! Stay tuned!

✅ Download the script from the tutorial here:

✅ Free Assets from the Unity Assets Store:

😷👕 Need a face mask / developer T-shirt? Drop by our merchandise shop and get a 20% DISCOUNT on your first purchase by using the discount code YOUTUBE. Just follow this link:

Some links might be affiliate links. Any support is truly appreciated so we can keep on making high quality content :-)

#learnunity #unitytutorial #videogametutorial

····················································································

Visit our website for more tips & tricks:

····················································································

Try our Bumperball game:

iOS:

Android:
Рекомендации по теме
Комментарии
Автор

This was very useful, thank you. And it is way more complicated than it should be. Even I could design a more user friendly dropdown menu than the one that is in Unity right now, jeez. However, I do have an issue with this: when I set it up the way you did, I have a field below script function in the inspector window which MUST contain an int - and whatever I put in there is the result of every option out of the dropdown menu...

The correct way to do this in Unity 2020 is as follows: declare a dropdown menu in the beginning of the script ("Dropdown" if you use normal text or "TMP_Dropdown" if you use the TMP version) and then don't give the function an int as value, don't give the function anything and give the if statements the dropdownObject.value to compare. Here is my example:

public TMP_Dropdown dropdown;

public void DropdownHandler()
{
if (dropdown.value == 0)
{
Debug.Log("first value");
}

if (dropdown.value == 1)
{
Debug.Log("second value");
}
...etc

I have not found a fix for the dropdown menu not scaling properly though, it's a complete mess visually. What has Unity done with this...

MrReese
Автор

Perfect, thanks!! Was so difficult to find a TMP dropdown example anywhere!! Excellent work Oxmond!

misterr
Автор

Short, Simple and CLEAN! Thanks a lot mate!

originalnick
Автор

Thanks, short and simple. God Bless you!

RobertGercia
Автор

Finally, a short useful tutorial i need

dasap.
Автор

Very simple, quick and easy to follow. Thanks! This really helped me out in the middle of a game jam :) .

williamobrien
Автор

Thanks, I love this video because it is very short and very useful

alaahoussen
Автор

Thanks, this has the information I needed. But to be honest the pedagogy has some issues. You're not really explaining what you're doing, you're just doing it.

cloudlessrainvisions
Автор

Thanks! This was very short and useful!

xermi
Автор

very usefull tutorial, thanks so much

sebas_tian
Автор

Thank you.
Is there any way to change the text before clicking the dropdown bar? I want mine to look like your thumbnail of this video.

hdkung
Автор

This was a big help, thanks! Can you do a tutorial on how to select an object on a panel in-game and then place that object on another area of the GUI like how it is on SimCity?

bobh
Автор

Quick question, why didnt you use a switch statement?

antonclark
Автор

If I choose a selection and switch the scenes the dropdown is on the default selection. what can I do that the dropdown selection is on the same selection than before I switch the scenes

tim
Автор

Hi, how about when the option clicked then video will play instead of showing text?

aeiouxyz
Автор

​ @Operngeist1 Thank you! That fixed it! For those who are having issues, go to the Main Object>Dropdown Script> Output change it from where it says: None> and choose "Output" Thanks again.

FlappyBandAid
Автор

Thought I'd put this in here, but I came up with another method which works the same, but is better if you have a large amount of items in the drop down. For my case I was checking an array of adjectives and assigning it to another object, which could be anything.

public void HandleAdjectiveInputData(int val)
{
if (val >= 0 && val < adjectives.Length)
{
selectedAdjective.clip = adjectives[val];
}
}

jakehartnoll
Автор

it isnt working for me, when i make the dropdown menu and add text the options stay white and they dont display text

jornnieborg
Автор

GRACIAS POR TANTO GENIO, QUE VIVA EL PROGRAMADOR Y QUE SIGAN LOS EXITOS. ABRAZO GRANDE

alanbursztyn
Автор

somehow its not working for me. the code looks good but when i pick one it doesnt change the text?

nghfre