How to Make a Title Screen in Unity / 2021 (Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to my channel in this video i'll be showing you how to create a simple menu for your unity game so as you can see i have a little uh game set up here where you run around collecting coins uh this was part of our last tutorial video so if anything here looks interesting to you make sure to check it out but today i'm gonna create a little title menu for this game so you have something to look at before you actually get into the game to do this i'm going to my scenes folder and i'm going to create a scene and i'll call it title and i'm just gonna open up that scene and as you can see it's just a blank scene with only a camera and since i'm just doing a simple scene here i'm just gonna change the background color to something a little more uh pleasing i'll just do a dark gray and the first thing i want to do is i want to add a title for the game and to do that i am just adding this text mesh pro element if you do not have text mesh pro you can get it by going to the package manager and searching for text mesh pro and installing so when i create this a canvas object gets created as well and i'm just going to call this title and i'll call this i don't know tutorial game and usually what i like to do with this is disable the wrapping i center the text and i'll make the title a little bigger maybe bold and i'll move it up a couple pixels all right we got our title so now we just need a button so we can start the game so i'm going to go ahead and go to ui button text mesh pro and i actually don't need the text on that i'm going to call this button start game and i actually went through and made some art for a couple of the buttons so i'm going to go ahead and use that for this one by selecting a sprite for the uh image component here i'll choose that and i'll set it to native size so it doesn't look all distorted and it's just a simple play button ui and i'm actually going to add my little texture here that way it just matches the rest of the game a little better and down here under the button component i actually don't want to color tint i want to sprite swap and when it's pressed i want it to change to this pressed in version of the sprite so if we play the game and i click on it there you go you can see it swapping out the sprite when i click it i'm not the best artist in the world so it might look a little funny but as far as information goes that's how you do that so when we click on it we want it to start our game in that first level that we have so to do that i'm actually going to add a script called start game and i will go ahead and open that in visual studio all right now that we got our start game script open we can add using unity engine dot scene management to the top of our script and what i'll want here is a public string and i'll call it level name and that'll just be whatever the name is of the scene that we want to load after clicking the button and i'm going to make a public void load a level function and this will be the function that gets called whenever we click that button and what we can do here is go scene manager dot load scene level name and now whenever we click the button and it calls this function it will load whatever level we give it so let's go back to unity and set that up so now that we're in unity i'm gonna go back here and my other scene i've just been using the sample scene but i'll just call it i'm gonna rename it to level one and the level we wanna call is level one and i'm clicking the plus to add a event on click and we're gonna select the function in our start game script called load level which should load level one so if i save this and play the game now i can click on that oh and i got a error in the console let's see what that is oh yeah so in order for this to work you have to go into your build settings and you'll have to add all the scenes you want in your final game so i'm adding the title scene first because that's the first scene i want the game to load in with and i'm also adding the level one scene so we have somewhere to go when we click the button so if we try this again it should work and there you go now you started your game awesome so that works the next thing you might want to do is maybe you'll have like a settings menu and you'll want to have a button here to click to bring up the settings menu so you could adjust some stuff so let's go ahead and try that out first thing i'm going to do is i'm going to make a simple settings menu i'm not going to go too crazy on it but here we go also i always forget to change this but what i usually want to do is change the canvas scaler to scale with screen size and i usually set it to 1920 by 1080. um expand uh there's probably a better way to do that but that's usually what i go with all right now that i got a little settings menu here where you could uh theoretically change the volume of your game um that's not actually hooked up it's just a representation of what you could have let's go ahead and add actually you know i should probably fix this too okay that looks a little better so now that we have our little settings menu i'm going to go ahead and i like just to make it easy i'm duplicating our start game button all right that looks okay and i'm going to select our settings icon and for the sprite swap i'm going to select the pressed version of that icon and we can remove this start game script and for this on click event i'm gonna actually want to take our settings menu game object and put it in there and then i can do a set active to true and i can change that so i just renamed our button to settings added the settings menu to the on click event and i am setting it to true so if we go ahead and start our game and we click on that button our settings will now come up and we can adjust them but now we want to be able to close our settings but there's no way of doing that so let's go ahead and add a button for that under settings menu i'm going to go ahead and add a button dash text mesh pro here i'm going to say i'm just going to call it close i don't have any special art for a close button yet so maybe in the future all right our button is a pretty big and doesn't look very good but it should work out just fine so when we want to what we want to do is when we click on the button we wanted to close the settings menu so what i'm doing here is i'm adding an on click event dragging our settings menu there and like we did with the other button i'm clicking set active but i'm not checking the box here so that should set it to false so if i disable that go back into our game and we try it i can click on our settings adjust our volume and close it and start our game if you like this video and want to learn more feel free to subscribe or check out my other videos on unity game development and until next time thanks for watching bye
Info
Channel: MichaelsGameLab
Views: 933
Rating: undefined out of 5
Keywords: sprite, unity, game dev, unity 2d, 2D Game, unity 2021, unity tutorial, tutorial, game developement, developement, c#, unity c#, programming, unity programming, unity title screen, unity menu, unity ui, unity button, unity scene loading, unity press button, game dev title screen, unity game menu
Id: NRUk7YzXyhE
Channel Id: undefined
Length: 11min 24sec (684 seconds)
Published: Mon May 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.