Unity UI Tutorial Dropdown C# Scripting

  Рет қаралды 69,858

Jayanam

Jayanam

4 жыл бұрын

Here is a Unity UI tutorial on how to fill a dropdown dynamically with C# scripting and also how to react on value change and write the selected text to a UI Text field.
It is a request video and I get many request for Unity UI. If you have questions or other issues that you would like to see a tutorial about just let me know.
See my social profiles here:
Instagram: / jayanamgames
Twitter: / jayanamgames
Facebook: / jayanamgames
Patreon: / jayanam
Merch Store: teespring.com/de/stores/jayan...
Production Music courtesy of Epidemic Sound: www.epidemicsound.com

Пікірлер: 40
@AnimalPlayground
@AnimalPlayground 3 жыл бұрын
For those that missed the syntax at 3:20 (kzfaq.info/get/bejne/i7iDbKRlu8XdfJc.html) , the text is: dropdown.onValueChanged.AddListener(delegate { DropdownItemSelected(dropdown); }) ;
@shadow_lev-9652
@shadow_lev-9652 Жыл бұрын
I thought it was a typo!
@creatingwithlove
@creatingwithlove 3 жыл бұрын
THANK YOU! Your tutorial is straightforward, to the point, easy to understand, and explains each step as you go. PLEASE make more of these kinds of tutorials.
@proprogramer4005
@proprogramer4005 2 жыл бұрын
quick, efficient, simple. Great tutorial and exactly what i needed. Thanks
@christopherdoiron4294
@christopherdoiron4294 3 жыл бұрын
This is the video that helped me get my SO's from an array into a list into the dropdown. Finally players can choose a starting job!
@nicka.9057
@nicka.9057 2 жыл бұрын
Just started the video. I was looking for the exact same thing.
@saidjonasrorov1721
@saidjonasrorov1721 2 жыл бұрын
thank you bro, i just didnt find combobox and finded analog for it, thank you very much!
@CamperJohn
@CamperJohn 4 жыл бұрын
Seems easy enough...good info to know...thanks for sharing.
@JayAnAm
@JayAnAm 4 жыл бұрын
You are very welcome
@AlbanyTimbo
@AlbanyTimbo 4 ай бұрын
Excelente tutorial! Obrigado!
@chocobarrel
@chocobarrel 3 жыл бұрын
Could you please make a video on using 2 dropdown boxes in tandem? and how to read dropdown values on button click ?
@FuzzyDPozzy
@FuzzyDPozzy 3 жыл бұрын
you are the best thank you!
@JayAnAm
@JayAnAm 3 жыл бұрын
Thank you, great you like it.
@ronwelch749
@ronwelch749 3 жыл бұрын
Great video. I have a recurring problem that I was hoping this video might solve because I might have been doing things wrong, but it happens here too. If i add more than 10 items to this dropdown and use the scrollbar to navigate, the scrollbar goes back to the top on its own. It fights me if I keep a hold on it, and when i let go it zooms to the top...Any ideas? Thanks
@osanetebatista
@osanetebatista 4 ай бұрын
thx guy!:D
@leowong9732
@leowong9732 Жыл бұрын
Hi there, it's a great video. I am new to C# and while following your video step by step, I had a "NullReferenceException : Object reference not set to an instance of an object" when using the TextBox in the DropdownItemSelected method. How does the public declaration of TextBox as type Text in the script links it to the UI Text created in the SampleScene? I am a little lost on how the script connected to this text object. I had to add a tag to the text object and an additional GameObject.FindWithTag("textTag").GetComponent() in the script to make that connection in order for the code to run for me. Please advice if I did miss something along the way, thank you very much.
@Andredy89
@Andredy89 2 жыл бұрын
Hi! Can you plz tell me how to expand(open) a dropdown menu from a script? When I say like dropdown.Show(); it does nothing(
@FatBanana
@FatBanana 4 жыл бұрын
can you make video about searchable dropdown?
@JayAnAm
@JayAnAm 4 жыл бұрын
I'll put this to my list
@MaestroMarc
@MaestroMarc 11 ай бұрын
I have a request, could you please make a video about how to write a C# script that causes the options in a dropdown menu to cause different scenes (represented by level numbers) to be displayed and revealed once the previous scene has been beaten? And once all scenes have been completed in an option for the next option to become visible in the dropdown?
@DariuszMakowski
@DariuszMakowski Жыл бұрын
my drop down does not render in vr. Its over existing UI so I guess I have zdepth issues? How can I change location of drop down to be different/in front of other ui? I can still click on it, but its ghost clicking atm,
@firstnamelastname2971
@firstnamelastname2971 Жыл бұрын
how to use playerprefs to save?
@Glitchyetiad
@Glitchyetiad 2 жыл бұрын
hmm got an error at dropdown.options.Add(new Dropdown.OptionData() { text = item }); it says theirs a null reference, "object reference not set to an instance of an object"?? any ideas, I've kept to the script so im not sure?
@Glitchyetiad
@Glitchyetiad 2 жыл бұрын
found the issue, if your using the version of unity(2021.3.0f1) then be careful between a tmp_pro dropdown and the old dropdown verisons
@leonelchailand8479
@leonelchailand8479 Жыл бұрын
do we need to pick the old one?
@mohsaniqbal322
@mohsaniqbal322 11 ай бұрын
Sir i want to use sprite image in dromdown menu
@muhammadtalhaali2541
@muhammadtalhaali2541 3 жыл бұрын
LOve you sir
@JayAnAm
@JayAnAm 3 жыл бұрын
:-) Thx!
@muhammadtalhaali2541
@muhammadtalhaali2541 3 жыл бұрын
@@JayAnAm short precise tutorails are the best helped me in 4 mins :)
@spacedreamer99
@spacedreamer99 2 жыл бұрын
Hi, I don't know if you still answer to comments x') On my dropdown I somtimes change the value of it through script. However, I want an action to occur only when I change the value when clicking the dropdown value and not when it is changed by other scripts. Any idea?
@JackFoz454
@JackFoz454 2 жыл бұрын
I have no idea whether there is a built-in way to do this, but I think you could achieve it using some fairly simple code of your own. Create a boolean variable called something like suppressValueChangeActions. Add a line at the top of your TakeActionOnValueChanged method: if (suppressValueChangeActions) return; Hopefully it's clear that you can now set this boolean variable to 'false' whenever you want value changes to trigger the follow-on action, and 'true' when you don't. For example: suppressValueChangeActions = true; // Change the value through script here suppressValueChangeActions = false; Hope this helps!
@FedKass1
@FedKass1 Жыл бұрын
Works great, except the default value is not showing up in the dropdown for whatever reason - if anyone could help that would be greatly appreciated!
@FedKass1
@FedKass1 Жыл бұрын
Just in case it helps somebody: I had to add 'controlMode.RefreshShownValue();' after 'DropdownItemSelected(controlMode);' in order to display the default value in the dropdown
@sopoic7587
@sopoic7587 2 жыл бұрын
can i get the script ?
@glalkia713
@glalkia713 4 жыл бұрын
Sir plz make tutorials on unity textures
@JayAnAm
@JayAnAm 4 жыл бұрын
Ok, thx for the input
@glalkia713
@glalkia713 4 жыл бұрын
@@JayAnAm thanks for the awesome tutorials sir I've learned so much from them
@corneliawidya6985
@corneliawidya6985 2 жыл бұрын
the script is not working :(
@bryan3dguitar
@bryan3dguitar Жыл бұрын
Make sure you have the full line to call the "AddListener " delegate script in the Start method as shown below: dropdown.onValueChanged.AddListener(delegate { DropdownItemSelected(dropdown); } ); Thanks to John Liverdos for posting this in 2022.
Unity UI Tutorial - Dropdown with Images!
21:37
Sloan Kelly
Рет қаралды 42 М.
Unity Button Click Events C# Script Tutorial
4:10
Jayanam
Рет қаралды 334 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 10 МЛН
ВОДА В СОЛО
00:20
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 32 МЛН
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 52 МЛН
Learning C# In A Week... Otherwise I Fail University
9:04
Выпадающее меню - Unity легко
6:52
Graphical Design
Рет қаралды 21 М.
Unity3D UI Toolkit Tutorial - Main Menu
29:30
Bunny Coding
Рет қаралды 17 М.
Searchable Dropdown List Unity
6:29
p0mf!
Рет қаралды 8 М.
Unity 3D: UI  Dropdown
11:29
Rodrigo Madrid
Рет қаралды 1,5 М.
Dropdown show images(unity)
8:47
saeng gang
Рет қаралды 738
Drag and drop in Unity UI - create your own inventory UI!
12:47
Coco Code
Рет қаралды 100 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 10 МЛН