Simple Question Dialog in Unity! (Yes-No Ok-Cancel Unity Tutorial)

preview_player
Показать описание
👍 Learn to make awesome games step-by-step from start to finish.

🔴 RELATED VIDEOS 🔴

💬 Learn how to make a simple but extremely useful Question Dialog Window in Unity!
Perfect for asking the Player a question like "Do you want to Quit the game?", "Really change settings?" and so on. Also you can easily change the buttons from Yes/No to Ok/Cancel or anything else.
Since the Question Dialog works with Delegates it is super adaptable to any scenario.

🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

#unitytutorial #gamedev #unity #unity3d #unity2d #indiegame​ #gamedevelopment #madewithunity​ #indiedev​

--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.

I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.

I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.

--------------------------------------------------------------------
- Other great Unity channels:
--------------------------------------------------------------------

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

Normally I use my own custom Button class but here I used Unity's built-in Button which works in a different way.
If you add a listener on ShowQuestion(); you will be adding more and more listeners every time you call the function which will make it call all previous Actions instead of just the Action on the last question.
So instead you should make a YesBtnClick() and NoBtnClick(); and just add the listener once and in those functions you simply trigger the actions which you save as member variables instead of saving the button references.


🔴 RELATED VIDEOS 🔴

CodeMonkeyUnity
Автор

Hi Hugo, happy to see this kind of tutorials back, as you said it :D

javisin
Автор

Hey this is exactly how I made the "yes or no" notification type at my Unity dev. job! To think just 3 years ago I was in school worshipping your tutorial videos... Not only did you teach me very specific things like how to make a minimap, you introduced many C# and Unity concepts (lambda expressions, tasks/jobs, actions, interfaces, scriptable objects, etc) early in my development, peaked my curiosity, and ultimately allowed me to accel. (And build some really awesome games in the process heheh!!)
Thanks Hugo, I'm forever grateful 🙏♥️

brandoncoulombe
Автор

A few notes.
I don't know how it is with UnityActions as I mostly use standard Actions, but there should be code to also remove the listener with the way you set it up, otherwise the callbacks will keep on piling up. With regular actions you are running a risk of null exceptions, or memory leaks when not explicitly removing them.

I would definitely go with the way of assigning references in the editor trough [SerializeField] as with the Find function you are depending on the developer naming their gameObjects correctly.

Personally, I would store the yes/no callbacks in a variable and have permanent OnYes, OnNo functions in the OnClick event that than call the callbacks stored in variables. That way there is only one callback added to each button and can be easily removed.

nocturne
Автор

I like how you break things into sections since it's easy to create reusable unity prefabs and modular scripts.
I much prefer your style over the run on everything in one scripting style, you usually find in lower quality tutorials and books.

etherealregions
Автор

We want more videos like this each week :D. That is why we subscribed for. Thanks for making this video.

Kalponic_Studio
Автор

Great tutorial as usual. I pretty much built my confirmation dialogs the same way. One difference though is I prefer to bind the listener to the buttons only once (in onStart) and instead in ShowQuestion I assign the Action to a private var that is invoked when the listener is invoked. This is to prevent invoking the same listener multiple times.

firebiscuitgaming
Автор

Thank you for this, I have been battling to get my UI to do this, especially with chapter selection.

CyberStudios
Автор

Hi, I'm one of the first to see your video, greetings :)

ZackySalchichas
Автор

This was pretty cool! Keep up the good work man

HaTesful
Автор

Another really quick and useful tutorial. Thank you, senpai.

MarushiaDark
Автор

make sure to remove all listeners from the yes and no buttons when the window is disabled or else multiple instructions will run simultaneously

_sIash
Автор

Correct me if I'm wrong but I don't like what you did with the Awake method, why are you "finding" these component when you can just serialize these fields and just drag and drop and then save the dialogue as prefab ? there is nothing dynamic or unknown here, so there is no reason at all to make a "search", i know the performance is almost meaningless but one of the main reasons why i love this channel and had the bell notification ON is for how good the tutorials are from all aspect, and this kind of "rushed" code will encourage bad habits among beginners, I hope this didn't came up as offensive or anything, cheers!

alaslipknot
Автор

Your name is Hugo I was in your stream

neelamshahi
Автор

This video was very informative, thanks!

zehsofficial
Автор

Hello Hugo, im wondering if you could make a video in a dialogue system but with voices, i mean how to manage the voice lines to play at a certain order and loading the sounds for the level

Extremogato
Автор

Best is to have a (firsttime) setupwizard aviable before the OS is booting; so BIOS level. This architectural feature also allows for a complete new way to interact with settings, which are mostly .xml files.

MsDuketown
Автор

5:01 Headphones warning, there's some serious volume mismatch!

Venet
Автор

If you were to make it so the textbox would be triggered by a button what would you do?

George-lbgt
Автор

Great Video Can you make video making simple inventory system

supertenchoo
join shbcf.ru