Welcome back, my fellow game developers.
In this video, we are going to
add a bit of functionality to our deaf screen.
So currently when we walk around,
we are alive and everything's good.
When we die, we have
the option to either restart the level,
so we start off on the same level,
or we have the option to go back to
the main menu and cry a little bit.
So let's not waste any more time and let's get started.
Okay, so now we have everything.
We have the title, we have the victory.
It's time to do something about deaf screen.
So currently when we die,
you can see right now if we run the game with AI,
you can see we have the UTI,
we have the cooled lot,
but there is nothing to do.
So we've just sit there
until we stop the play mode again.
We don't want to do that.
We want to have a continuous loop in our game.
So I'm going to do is I'm going
to go into the deaf screen.
And here I'm going to right-click and I'm going
to create a button or you know what?
Before I do all of that,
I'm going to issue you a challenge.
And your challenge is going to be to
create the two methods and the two buttons.
So first of all, you need to create two buttons,
want to restart the level and
want to go back to the main menu.
You will need to create a method
for each of these buttons.
And then you'll need to assign
the functionalities to these two buttons.
So with that out of the way,
I believe you already know how to restart a level.
You need to load the scene that we are
currently on which we can get by getting seen active.
So pause the video right now and go do the challenge.
Oh, okay, welcome back.
How did you get on with that?
So because the current challenges
are getting a bit
boring because you already know everything.
So I just loved the whole video to you.
And I'm editing things without seeing even depth screen.
So let's turn the Alpha to
one so we can properly see the button.
And let's see what we're going to do in here.
So we have the button.
Let's select this one and let's make it bigger.
Move it to the left.
And then in here we are going to
remove the text and add our own texts.
So everything I'm doing in here we have already covered.
So say restart level.
And let's set the proper everything,
the proper everything and size, max,
the max and the obviously the button right here
should have the UI Elements Buttons
and should have this sprite right here.
There we go. So now we
can increase the text and make it a bit bigger.
There we go. We make it bold.
Bold, I mean bold.
So now we have the bold text and let's make this button.
I've been bigger. Yeah, how does that look?
I think it looks pretty good.
So I'm going to duplicate this.
Move this down here.
This will be the main menu button,
and the text will be the main menu.
There we go. So I think that looks good enough.
Let's maybe just know this, the text.
I want to increase the text size a bit for the restart.
And there we go. So I think that looks good enough.
Save that.
And now let's go ahead and add the functionalities.
So in Scene Manager,
we want to create everything.
I mean, not unseen manager,
you are a manager.
We want to create the methods that take us from
or restart the lover or take us to the main menu.
But the thing here is,
and this is a philosophy in game development.
And where do you actually want to do this?
So the UI Manager, what does it do?
Does it take us from one scene
to the next? No, it doesn't.
It just manages the UI and this is its job.
So a better place I believe,
of doing this method or creating
these methods as in the level manager,
but also at the same time,
we don't want the buttons to
have access to the level manager.
We just want the buttons to be able
to change things in the UI Manager.
So we are in a bit of
a pickle if you want to call it that.
So what I'm going to do is I'm going to trust
my gut instincts and I'm
going to create the methods in here.
It's a public void restart level.
And the way we restart the level is we simply
get the scene manager, the load seen.
And which scene are we going to load the scene manager,
dot get active seen that build and x.
So now we just load the scene
of the current active scene.
That means we reload the level and then public void re,
return to main menu.
And in here we are going to get
this scene manager dot load scene.
And we'll just load the scenes 0 because we know that
the scene or the title scene
or MainMenu scene is on the index 0.
And now we'll go back into the UI Manager.
And in here we are going to create the same methods.
But instead of actually doing the things,
we are going to access
the level manager and do we have an instance?
Yes, we do have an instance.
So in here we are going to get
the level manager dot instance, dot restart level.
And let's do the same in here,
but instead of restarting the level,
return to main menu.
So save that, go back into Unity.
And I know this feels a bit redundant.
I know this feels as if we're
doing the same thing again and again.
But I believe that this
is a more proper way of doing things.
So we can go to the UI Manager,
restarted level and main menu.
Go to your manager,
and return to main menu.
Save that.
Let's turn off the depth screen.
First of all, let's apply the changes
that we've made apply.
So now we turn off.
First of all, we'll set the Alpha to 0.
We will turn of the deaf screen.
Larger the game die.
And now we have the restart and main menu.
If I click on the main menu,
I go back to the main menu.
Excellent.
Let's try this again with the
same of restarting the level.
We die, we start level. There we go.
We are back on level 2, baby.
So excellent job.
I hope you enjoy it. I hope you did this challenge.
I hope you tried your best and I
congratulate you if you did it from start to finish,
all on your own.
I'm going to stage everything,
sage all commit the changes.
Created a way to either restart the level
or go back to Main Menu upon death.
And not a way created.
Two buttons to either
restart the level all go back
to the main menu upon death.
And when the changes.
If you haven't already leave me a review,
if not, you can wait
just a little bit and then leave me a review.
This is the perfect time and I'll
see you in the next one where we will be
creating one of the cooler aspect of any game,
which is the pause menu.
So I'll see you then.