How To Make A Keypad in Unity (EASY!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and so in this video i'm going to be showing you how to make a really simple keypad inside of unity um i already made it but i'm just going to basically explain to you how i did it and how easy it really is so over here in the hierarchy all i did was create a canvas you can do this by right clicking on your hierarchy coming down to ui and then selecting canvas and then inside of the canvas i just have a few objects a character holder which is the input field so again right click ui and then an input field and then everything else is just buttons i just renamed the buttons so that it's easier to understand what it is and then obviously inside the button it will be text this already comes as soon as you place the button so you don't have to worry about that um so i have it one through nine and then zero uh i also have a clear button and an enter button um once you have that you also want to create an empty game object so right click and then create empty and then you can name it whatever you want to but i named it keypad once you have all that set up you can come down here into your assets folder right click create and then c-sharp script and then inside of that script well you can name it whatever you want and then go ahead and open it up and this is basically just going to be the code for it um so up here you know you have to assign all of the objects so my input field and all my buttons and then what i'm doing is having it so when button one is pressed then the input field is getting the current text of the input field and then it's plusing well adding onto one and then it's just doing it for every number that's pressed so button one would add one button two would be two and then so on um for the clear button is just the character holder which is input field dot text will be null and then enter it we have an if statement and so it's saying if the character holder dot text is equal one two three four then it will be success if not then it would be false now if you don't want to hard code um the password you can always make a public string um you can name a password and then just have it blank and then down here you know instead of doing like one two three four um or like having this you can just have the string which is the password equal whatever you want um just to make it a little bit easier um or if you're just against hard coding but personally hard coding doesn't matter to me so i'm just going to keep it like that and then back into unity all you want to do is drag and drop the keypad script into the keypad object and then it will appear like this um yours would be empty um so all you want to do is basically just drag and drop everything so at the character holder just drag that in and then drag in all the buttons making sure they match the clear button the enter button um and then the last thing you want to do is click on every single button one at a time scroll down underneath the button field you will have this on click i'll just show you it will look like this um and all you want to do is just drag in keypad click on no function come down to keypad and then press whatever button that you clicked on um so it would be b1 and then you just want to do that for every single button as you can see i have all mine set up i have mine as clear and then enter so if i go ahead and play this i do one one one and i show it failed so i'll just go ahead and clear it and then i'll just do one two three four and then success um so that's pretty much all for this video it's really simple um if you want this entire thing and you don't want to set it up um i will leave a link down below to my patreon it's only three dollars a month um usually i would release a lot of stuff for free especially like this but since i did explain it to you all in the video and i have showed the code multiple times um if you really really need it and you don't want to type it all out and you basically just want to copy and paste then you can just pay the three dollars um so yeah if you have any issues with this just comment down below and if you'd like to see anything else related to unity or c-sharp just comment down below um let me know as always thanks for watching and don't forget to like comment share and subscribe
Info
Channel: It’s Networking
Views: 2,437
Rating: undefined out of 5
Keywords:
Id: sURDTT8UkfQ
Channel Id: undefined
Length: 5min 53sec (353 seconds)
Published: Mon Jul 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.