Welcome back, my fellow game developers and this video we are going to put our buttons to use.
So if you remember, our buttons didn't do anything, but now when we hit the items button, we get
a different panel.
When we hit the stats, we get another different panel.
And when we quit the game, you see that we with the game, unfortunately, because we are still in
the unity editor, the quit doesn't do anything.
It will later on when we build our game.
But for now, it works by printing out something to the council.
So let's not waste any more time and let's get started.
Okay, so currently, if we run our game, you can see that if our game runs any day now, if we hit
the key, we have the menu.
Everything is set up pretty much correctly.
Maybe we need to fix this on the little hill right here.
But the buttons aren't working.
Why is that?
Well, because we haven't given them anything to work with.
So we need a way to whenever we click the status button or the items button, we want to open up another
menu.
So we're going to open the canvas, open up the menu so we can see everything.
And we are going to go ahead and put all of the character info under a single empty object.
So this will be the character info and we are going to drag all three into the character and right here.
And next thing we're going to do is we're going to create a new panel.
So go to your eye panel and we are going to make it a little bit smaller.
So it fits in right under the buttons and we're going to give it the background that we are using.
So go to the elements, give it the background we are always using and turn, oops, where is it?
So we turn everything on completely.
There we go.
We can even make it bigger.
So let's make it just oops.
No, we want to make it a little bit bigger.
So there you go.
So we have more space to work with and this panel is going to be the items panel.
So the items or just items or items panel, it depends on you what you want to name.
It just needs to represent what the items are correctly.
OK, great.
So now we need a way to turn this panel on and off when we click the buttons.
Now, there are many ways we can create a method and the menu manager to handle this or we can go to
the items button.
So if we open up the buttons, we go to the items button.
If we scroll down, you can see on the button game component or the button component.
We have a unclick and this on it does what it says.
Whenever you click it, it does something and we can add in here a function for it to do so.
You can see currently we can add an object and this is where we will be.
Oops, sorry.
So if we go back to the items button down here, we can drag the items panel in here if it lets us solve
the items panel and you can see that currently there is no function if we click on it, we have many
options and one of them is the game object so we can access the game object and do many things with
it.
So for example, the string name and so on.
But what we're interested in is this set active.
So if you click on here, you'll see that we get this small checkbox and this small checkbox represents
if we want to set active to true or if we want to set the active to false, sort of set the active to
true, that means this panel will be set to, well, active.
So now if I just turn off the items panel, if we run the game and let's turn off the menu, turn it
back on.
So if I click on the items, there we go.
How cool is that?
If I click again, nothing happens because it doesn't have anything else to do.
It just turns on the items panel.
So this is how we are going to open up and the closed different menus.
So with that knowledge, it's time for you to create these states panel and do the challenge.
So your challenge is to complete the start button.
So you'll need to turn on these stats and everything else off.
And I'm not talking just about the character info.
I'm talking about the stats.
What do I mean by that?
As you can see, we have a stats button, which is different than the regular character information
that we've created.
So with that knowledge, let me go back in here, pass the video right now, create the stats panel.
Doesn't need to have anything in it, just like the items.
You can duplicate the items panel and you'll need to set these stats.
But so was the video right now and go to the challenge.
OK, welcome back.
So let's go to the items panel, we are going to duplicate it and will change it to the status panel.
We'll see what is that this panel does later on.
So we'll go into the stats.
We are going to turn on the status panel will drag it in here, said the game.
Object to set active and we'll set it to.
True, but not only that, the challenge also says and everything else off.
So we'll go back and here we are going to create another unclick object under the stats panel.
We are going to drag the items panel and here we are going to go to the game object set active and we'll
set it to false.
So now when we click the status button or the start button, we are going to set active the stats.
So this should be this.
That's not the status.
So these stats.
So when we turn on the stats panel, we turn off the items panel and we'll do the same thing right here
for the items.
So how are we going to know the difference?
We're not right now.
Later on, we'll see that there is a difference.
If you want, you can add maybe a little something that differentiates the items from the stats.
Let's go ahead and do this.
Actually, that's a good idea.
I just thought of it.
Let's just make it a bit smaller.
So now we save that.
We are going to turn off these stats panel.
We are going to run our game.
Let me just turn this back on.
Go to the items.
There we go.
This is the items panel, the big one.
Now, we should have a smaller one when we had the stats.
There we go.
We have a smaller one.
We still have the characters right here.
You can also turn them off.
So character info should only come up when we enter.
So we'll see how we can figure that later on.
We also have the last thing, which is the button.
And for that, because we want to quit and go out from our game, we are going to create a method for
that.
So we'll go into the menu manager.
We will create a method in here and it's going to be a public void quitte game.
And in here, we are going to write application that Kuwait so what this does, it will take us out
of the application, but because we haven't built our game yet, we are still using it in the unity
editor.
It won't do anything.
So what we'll do is we'll use debug that log.
And we'll just print out a message in here that says we've quit the game.
Save that, go back into unity and let's see how we can do this.
We are going to.
Go into the button, scroll down and on Click Object, we are going to where is it?
Where is it?
We are going to drag in the canvas because we are using a method which is on the menu manager.
So where is the menu manager?
It's on the canvas.
There you go.
The menu manager is on the canvas, so we drag in the canvas on the object that's being asked for in
here.
The nonfunctioning will click on it and you'll notice that we should have a menu manager.
And in here we can access all the methods that are there.
And one of them is with game fed images, also one of them.
So whenever you want to call a certain method from the unclick, make sure that it's public.
So we are going to save that.
We are going to turn off the menu, that we turn off the menu, we'll run our game with had the key
will click acquit.
And there you go.
You can see the message printed out to the console with with the game.
So with that done, I hope you enjoy it.
In the next video, we are going to be creating our stats by adding everything we need to in that.
So I'll see you in the next one.