Welcome back My favorite game developers
to a brand new long video.
And in this one, when we run the game,
you'll see that we have the pine bought invader 2D.
Why does it sound like that?
But anyways, we have two buttons.
The exit button that just displays this text right here,
and the Start button when we choose it, there we go.
We go to the first level.
How cool is that?
We can shoot, we can get help,
we can also die.
So let's not waste any more time and let's get started.
Oh, case.
So time to create a couple of
menus and we are going to start with the title screen,
because obviously every game needs a title screen.
So what I decided to do is to have the title screen,
the test1, and I'm going to convert it
into the title screen.
Yes, reload.
And I'm going to remove the skeleton.
I'm only going to keep the player and
I'll add a couple of breakable items.
So in the prefabs.
And let's increase the size in here just a bit.
And where is it?
Pickups portals, rooms.
Okay, so a couple of breakable parts.
So I'll add one here and another one in here,
and another one in here.
And just a couple of parts that we
will have fun destroying.
And in this menu,
we will also have the two buttons that will
tell us to either start the game or exit the game.
So let's go ahead and do that.
I'm going to right-click in here.
I'm going to add a UI canvas,
and this will be the main menu canvas.
I'm going to set the event system in here.
I'm going to make sure that it is I'm sorry,
as screen space overlay and make sure that
the scale will screen size.
And there we go, 1920 by 1080.
Hit Enter, double-click so
we can see it properly in here.
And what are we going to have while we
are just going to have the screen where we move around.
But we'll also have
two buttons and the name of the game op here.
So maybe we should make this a bit smaller.
I don't know.
I was still thinking of how
are we going to fit all of this.
Maybe we can try to select
all the pots and the dome player and
just make all the parts a bit smaller too on the scale,
maybe make them 0.30.20 to that.
Still small. 0.50.5? Yeah, sure.
And then they don't player is also 0.50.5.
So there we go. If we try to run the game
now with our little tiny dude.
Or as you can see, he is still very big
and he cannot pick up the items
because the scale is very small.
That's because the, I just
realized that the animations will keep him big.
So let's bring him back to one.
And no worries, we'll try to fit everything in here.
So back to one.
Save that, okay, enemies run the game.
We will have the sprite guy.
You will be walking around.
He can not pick up things because in here
we have some kind of error.
And that's because we don't have the manager,
we don't have an entrepreneur enter on the coin.
There is a problem. Why is that?
Well, because the game manager isn't
available also on the coin.
So we're going to stop the game.
And we're going to select all of
these parts and make sure that the item dropper,
Let's just remove the component for
now and just keep the breakable so we avoid any errors.
So there we go, we break some pots and have fun.
And we'll also add two keys in here to allow
the player to select whether
to exit or to continue the game.
So in our screen and our canvas right here,
I'm going to right-click select your,
I add a text Mesh Pro.
This will be the title.
So game title, so time bot,
invader, I'm not sure I want to call this may be doomed,
bought and Vader, but let's just keep it as it is.
Changed the font auto size,
increase the max, and let's make it a bit bigger.
Let's set it in the middle.
Let's increase the max even more. So there we go.
We need a big, huge title 40 time both
invader to d. And we can add some underlay,
some lightings on glow.
So for example, we can increase the or
the underlay and add
a color in here to make it a bit cooler.
So go ahead, label this,
increase the softness, the offset on the y,
or something like that.
So choose the colors that you find appropriate.
Maybe make this one red or black or antinode.
No, black is bad.
Let's see, maybe increase this fully
red and on the Y, increase it up.
So there we go. So we have
something like a time bot and Vader 2D.
And it's not very pretty,
but it does its job.
And now we're going to add two more buttons.
So in here I'm going to right-click
and UI and add a button.
This is going to be the start button.
And I'm going to move it a bit to the left.
And this is where we decide where we want to put it.
So because we don't have too much space,
you can see how I'm looking at the game.
I'm going to set them maybe right here.
Let's see if we run the game.
How does that look?
So having a button down here,
no, I think that's not bad.
That's not bad at all.
So I'm going to maybe increase the size.
And in the resources.
We can go in here and you can find
the menu elements that I've provided you with.
So these are the buttons.
So back in our sprites, let's see,
do we have something under the UI elements,
UI elements and right-click, create 140 buttons.
Open this up, and let's
drag the buttons all the way into Unity.
And let's see what we have in here.
And let's go to multiple lie Sprite Editor.
That's slice these babies up.
There we go. So these are perfectly
sliced with the shadows.
So apply the changes.
Now we have these and I'm
going to select the Start button.
And as you can see, we have
the normal React component that we are used to.
And we have also the image
and the button things right here.
And you can add an on-click event on this button.
Whenever it's clicked, you can change the way it behaves.
So if the normal color, for example,
can be completely black or white or red or whatever,
you can change the highlighted color.
So for example, if we move our mouse over this button,
a free press the button and becomes, for example, green.
And if we select, I don't know,
selected color, I'm not sure what that is.
So if I run the game right now,
you'll notice that if I move
over the button and becomes red,
once I click it, it becomes green.
So this is how buttons work.
You can play around with a lot of things in here.
But what I want to focus on is
changing the sprite source.
And let's see what kind of buttons we have in here.
So something not good happened in the Sprite Editor.
And how many sprites do we have?
1, 2, 3, what are these empty things in here?
I don't like the looks of this, but anyways,
let's try to add this button. There we go.
So you can see this is the button that we've added.
Let's try to set it may be to
native size or maybe increase it on the Y.
So there we go. We can set two buttons
on each side of the title screen.
And maybe you can add a different kind of button,
may be this one which is a bit more clear.
I think it's better.
So now when we run the game,
you can see that we have
a really nice looking button and it
even changes color when we press it.
And maybe you don't want to have that kind of thing.
Maybe the only thing that you might want
to have is not to have this pressed.
Maybe we can make it darker or
something or keep it as it is,
but just change the alpha on it,
which is also a good idea,
but I'm going to make sure to have it some kind of
green color just so we know that
we are pressing this button.
And now with that we have the start button.
Let's duplicate this and move it to the left.
And this will be the exit button.
So Exit button.
And now what we need to do or you know what?
Maybe I did this too soon.
That's just delete the X button
because we want to change the text.
And here you can see that we have button texts.
We don't want this text.
We deleted.
We will add our own text,
which is a text Mesh Pro.
And obviously we're going to make it the cyborg bold.
The auto size, increased demands,
set it in the middle.
And that's all, that's all that we need to do.
And I'm going to increase the size of this one.
So let's make it a bit bigger and set it in
the middle and just make sure that it fits properly.
Now the only thing that might bother us
here is that the when,
when we tried to change, for example,
the color of this one.
Oh no, no, everything is working.
So should we make it dark?
I think dark. That's first of all,
try to type the name, so start came.
Okay, so apparently, having it
completely dark is not the way to go.
What colors should we be choosing?
Maybe even we should remove the underlay.
But if we remove the underlay in here,
remove also the underlay up here.
So this is why sometimes I don't like to use
text Mesh probe because everything is kind of related.
We are changing the entire shader
of what detects mesh Pro is.
Shaders are a whole different breed of information.
So I'm not going to delve too deep into that.
So back in Unity.
And let's see how that looks.
If I run the game, is it visible?
So start the game and not very much.
When it becomes red,
it is more visible.
Maybe we can change the background of the button.
So I'm just playing around honestly,
I'm not sure what I'm doing.
I'm just testing things out just as you are.
No, I think this one is better for our start game.
And now that we have this one,
now we can duplicate,
call it the Exit button.
And let's move it to the side.
On the other side. And in here we are going to change
the text to access that.
Again. Hit Enter. There we go.
So now we have two buttons.
We have set up the menu.
We can walk around, we can destroy these things,
we can shoot around us.
We're using the very scary buttons.
There we go. And we can start the game, exit the game.
But as you can see, they do not
do anything right now and again.
So what we're going to do is add
a couple of functionalities to these.
So I'm going to go into the scripts.
I'm going to right-click and
create a folder for the menu.
Double-click in here, right-click and
create a C sharp script for
the Main Menu Manager.
And let's just call it menu,
main menu because we would have to add it
to the Main Menu Manager if we did.
What's the problem here?
We have a problem with the sound effects, I think.
Yeah, I think it's a problem with the sound effects.
The problem with a couple of things.
There are a lot of problems in here because we
didn't add all the manager and all of that stuff,
but we don't really care about it.
This will not be a problem
because we are not actually doing anything.
And at this level,
so now was the main menu.
Let's add it to the main menu canvas.
And let's double-click and open up the script right here.
So we are going to first of
all create a method for the exit game.
So public void exit game.
And because we are still in
the editor and have not implemented the game,
this will not be working.
But if we write application dot close,
I mean the application taught quit.
This will exit from the application
and quits the player application.
And as you can see, but because we are
in the game mode of the Unity editor,
this will not work.
So what we'll do is we'll just add a debug dot log.
And we'll say that we exited the game.
Trust me, when you do build this game,
this button will work.
Don't worry about it. Anyways, this will run the game.
And if we go back into Unity,
if we go to the exit button,
we can scroll down in here and in the onclick event,
we can press this Plus button and we can add,
first of all, an object which
we will access the functions of.
So if I add the main menu,
you'll notice that now I can access
functions and one of those functions.
So for example, I can access
game object and do a couple of things in here.
Maybe turn off the game object, direct,
transform, change name, and so on and so forth.
But I can also access the main menu.
And you can see here I have Canvas, canvas,
scaler, graphic, ray caster,
and all of these are components inside of
the main menu canvas that I've provided
the button with at it also contains the main menu.
So on the main menu,
I'm going to select it.
And you can see that I have
a lot of methods that I can use.
And one of them is the exit game that I just created.
So when I click on this one, I run the game.
I can walk around and do the things I do.
And then if I click on the exit game,
you'll notice that we exited the game.
Why we capitalize, I don't know,
but you can see that this button
actually works and I can press it.
So now it's time to create the start game method,
and that is going to be your challenge.
So set the scene and
the building index as the first scene
and the first-level to be the second scene.
So you remember the building decks.
If you don't, you'll need to go ahead and check it.
It's in the File Build Settings, I believe.
Yep. Yes.
So we need to start the game.
In order to start the game,
we need to load the first level.
To load the first level, obviously,
we need to have a scene manager
and all of that good stuff.
I hope you didn't forget how to do that.
It was a couple of sections ago.
Create the start game method,
make sure it's public.
And the method access the scene manager and
get the build settings of the current active seen.
And then you'll need to increase it by one.
And just as a small hint,
You need to access the scene manager,
get active scene and build index plus one.
So with that out of the way,
pause the video right now and go do the alone.
Okay, welcome back.
So first of all, let me remove the start and update.
I'm not sure we'll be ever using them.
And here I'm going to add
in the engine dot senior management.
And now I'm going to create a public void.
Void star game should
be capitalized and this one should not start game.
That's opened up the squiggly lines.
And in here I'm going to access
the scene manager dot load seen.
And what scene should I be loading?
Well, first of all,
let's go to the File Build Settings.
And the title screen is already the first one.
So what I want to do as I want to get the index
of this one and then increase it by one.
So I'm going to go ahead and get this scene.
Manager dot, get active scene.
And in here I'm going to get
the build index and I'm just going to increase it by one.
So we go immediately to the next scene.
Save that.
Now let's go back into our game.
And let's see if that works.
So I'm going to run again.
We walk around, we destroy things,
we exit the game, it doesn't work.
Start the game.
And it doesn't work because we have not
assigned how smart of us,
we have not assigned
the stop button to do anything at all.
So main menu, how many times will I make
this mistake until we finally save that? Run the game.
Let's start again.
There we go. So now we are on the first level.
How cool is that? And we know it's
the first level because we
have all the skeletons in here.
See, even though we didn't do any changes to this level,
but because we've changed the prefabs of the skeleton,
they can now pick things up.
Obviously, there is a couple
of things that we need to change.
But for now, we know that the start game works,
the exit game works.
We've created a title screen.
We are going to commit
our changes and we are going to see you or actually,
I'm going to see you in the next video.