Re UI.
So what we can simply do, we can move over to our hierarchy than canvas, and we can select the game
over UI, and we can press down Ctrl D to duplicate.
But uh, but if we do this then go over to Inspector Overrides and then click on apply.
All the changes will also be gonna happen our game vector UI, which we really don't want.
So how we can do that.
So in order to do it, we're gonna approach a different way.
Uh, to do that, we will move over to our project app assets and then prefabs folder and let's find
the game Over UI.
So I have it over here inside my prefab folder instead of duplicating underneath our canvas basically
in the hierarchy, we're gonna duplicate in this brief inside this prefabs folder.
So now if we just go over to uh, this game over UI, then go over to Inspector Overrides and then apply
all the changes.
Not gonna be changed change in the our game victory.
Goodbye.
So basically that is the thing.
And that is the reason we're gonna duplicate from, uh, we're gonna duplicate from inside this prefab
folder instead of underneath our, uh, basically underneath our canvas in the hierarchy.
So we're going to select our game over UI from that prefab folder where we turn it into a prefab that
game over.
Anyway, let's select that and let's press down Ctrl D to duplicate.
And we're gonna call this one something like Game victory or let's call it victory Y.
So let's right click on it then rename.
And I'm going to call this one victory UI victory UI.
And now what we're gonna do we're going to select our game over UI in the hierarchy.
Let's go over to Inspector.
And we're going to uncheck.
Basically we're disabling that.
And now what we're going to do we're going to choose our victory way.
And let's drag it over to this canvas top of this canvas GameObject in the hierarchy.
And as soon as we drag it, we can see it now.
And we need to change some, uh, some things right over here.
But before I do, I'm going to select my BG underneath my game over UI game object.
And let's drag it in the center in the Y in the zero.
So instead of saying you lost, we're gonna say something like victory.
So let's change the text inside of it.
So let's click over here header.
Let's go to header then text.
And let's go over to Inspector and Inspector.
Then scroll down to the this text component.
And we're going to say something else instead of you loss.
So we're going to say something like victory.
So let's say victory.
And now this is fine.
So now if we select our parent game object then go over to Inspector Overrides and then apply all the
changes we made inside this vector UI.
Now it's not going to be saved into this game over UI.
So if I open up my game over UI from that folder by double clicking on it.
We cannot see the change right over here, so that's why we just duplicated our game over UI in the,
uh, from that prefab.
Uh, prefab folder, uh, to create our UI.
So basically that is the thing.
So we're going to go back and in order to go back in a hierarchy, you can see the back arrow.
So just click there in order to go back.
And instead of saying retry we're going to say something like uh uh, we can say next, uh load next
level.
Or we can simply say next.
So let's select our retry button.
Let's go over to Inspector, and we're going to change the text inside of this button.
Uh firstly let's rename this button to something like next button.
So let's call it next button and next button.
And we also need to change the text inside of this button.
Instead of saying retry we're going to say something like next.
So let's click over here.
Let's choose the text inside of this button.
Let's go over to Inspector Text Component.
And we're going to say something like next.
And what we can do now we can simply move over to our parent game object.
So in our case vector UI let's go over to Inspector Overrides and then apply all.
So the changes we uh, we made inside this vector UI, it's going to be saved into this vector UI prefab
as well.
But it's not going to change in this game over here by since we just duplicated this victory UI from
that folder from this game over UI.
So basically that is the thing.
So I hope you get the idea.
And now what we need, we need a we need to trigger this vector UI in the Y, as we have done with this
game over UI.
So whenever I'm going to click right mouse button, I just want to bring up the game over UI in the
y axis to be zero.
So firstly what we're going to do we're going to select our victory UAI.
And let's select this BG underneath our victory y.
And let's drag it in the bottom.
And we need to do the scripting of it.
So so to to do that I'm going to select my scene management script.
Let's double click on it in order to open that up.
So as you can see so we need a reference of this BG BG.
Then we can just uh bring this up into uh in the y axis to zero.
So it's going to be center it.
So for that we're going to open up our script.
But before I do I'm going to select my player.
If I go over to Inspector Player uh we can see we have the reference right over here.
So we can do it here instead.
So let's open up our player script.
So what we basically need we need a reference of this BG from this vector factory UI game object, you
can simply say so we need a reference of it, then we can just trigger it.
So let's open up our player script.
So I'm going to select my player GameObject in the hierarchy.
Let's go over to Inspector then Player Script.
And let's double click on it in order to open that up.
And what we will do, we will go to top of our class underneath our UI title.
Let's make a serialized field a serialized field.
Sorry, we're going to make serialized field private.
And that BG itself a basically game object.
So we're going to type this game object and we can call this one something like victory V.
Let's call it uh victory victory BG something like that.
And let's close that up with semicolon.
And we're going to press down Ctrl S to save our script.
And now let's move over to unity.
So underneath our player Skip we will able to see another field just gonna pop up, uh, pop up, and
it's going to say something like victory y as we name it inside our code.
So it's going to pop up underneath our UI title in the inside, our player script in The Inspector.
So just wait a moment and once our compilation is done, we can simply drag the reference.
And if we move over, if we select our player game object in a hierarchy, then go over to Inspector
Player Skip.
Underneath our UI title we can see victory BG and it says non game object.
So what we need to do now we're gonna select our BG not this victory game object.
Basically we're gonna select the BG underneath our victory way and let's drag it over to that field.
Now we can see we have the BG basically this victory BG.
And now we need to trigger it.
So uh, for now we don't have anything like checkpoint or final point to get end of the level and win
the game.
So for now I'm going to test with right mouse button.
Basically, whenever I'm going to click right mouse button, I just want to bring up this factory UI.
And later on we're going to replace that with something else.
Like if we get an end of the level or we just win the game, then we're gonna bring up the victory UI
and we're going to do it later for testing purposes.
I'm gonna do with right mouse button.
So let's open up our player script.
And firstly we need to set the BG local position in the y axis.
You can simply say -1005 hundred.
Like as we have done with this BG basically came over a UI.
So we basically just gonna do the same thing.
So firstly we're going to move over to our start function.
So in this start of the game I just want to set the position of this factory y.
Basically the BG in the bottom, something like -1005 hundred like we have done with this PG so we're
gonna do the same thing.
So firstly we will go to victory BG that we have a reference of it.
Victory BG then we're gonna go to uh we, we're going to access the local position.
Sorry.
Firstly we will go to transform.
Then we're going to access the local position.
And we're going to set equal to new uh vector three which is going to have x axis, comma y axis comma
z axis.
And we're going to close that up with semicolon.
So in the y what we're going to do we're going to set it in the bottom.
So we're going to do it something like -1002 hundred if something like that.
And in the X we don't want.
And also we're going to put zero F in the X.
And we're going to do the same thing in the z axis which is zero f.
Now we just set the position in the start of the game.
So we need to trigger our victory BG to basically bring up in the center in the y axis.
So what we will do for that we're going to make a separate function.
So let's move it in the bottom.
So let's make the function somewhere we can make it anywhere we can uh let's do that.
Okay.
So I'm going to do it somewhere over here over here.
And or we can do it inside I guess.
Player collectible script right over here as well.
Uh, but we're going to do inside our player skip.
So let's make the function here.
And, uh, let's make this function public.
And for function we're going to type void.
And we can call it something like trigger trigger victory.
Trigger victory UI something like that?
Let's make first bracket and some curly brackets and what we want to do inside this function.
We basically want to bring up that BG in the center in the y axis.
Basically we just want want to set the y position to zero.
So it's gonna it's gonna be centered basically.
That is the thing.
So firstly we will go to victory UI BG then we're gonna use this lead move local Y as we already used
for our game over UI as you saw earlier.
So this line move local y, it's gonna take basically it's gonna move our this BG in the y axis.
So first thing it's going to take the position from uh basically where you want to move.
So in the y axis we want to move.
And we're using this little move local y.
Basically it's gonna move our victory a victory in the y axis only.
And as a first argument it's going to take the position.
So we're going to put zero F basically means center it.
It's gonna do.
And the second thing it's going to take the time, uh, to just move our PG to that point.
So we're gonna so we're gonna choose less than a one second, something like 0.8 f, uh, eight f,
and and we can just close that off with semicolon, but we want a little bit animation.
So that's why, uh, closing the brackets we're going to type dot set.
Uh set is set is out back something like that.
And make sure you make this first bracket you can use any uh any like that.
So we getting an error.
Sorry.
Now it's fine.
So you can use any like dot set.
We can use dot set.
Is our, uh, bounce like that?
It's totally up to you.
whatever you want to set.
So I'm going to use this set is out back.
And we're going to make this first bracket because this is a function.
And we're going to close that off with semicolon.
And now we're going to press down Ctrl S to save our skip.
And now let's move over to unity.
But we also need to call this function.
We basically just made the function and we never calling it.
So when I just want to call it once I'm going to click the right mouse button.
Then I'm going to call this trigger victory UI function.
Or we're going to call this function.
And this function is just going to move over to our victory BG.
And it's going to move our BG in the y axis only.
And we just pass zero basically means center it.
And the second thing it just takes the time.
And you can use dot after closing the brackets the animation that you want or or if you don't want any
animation then you can just close that open semicolon.
And that's all since I want animation.
So that's why I just said set is out back and you can use anything like that.
So I'm gonna move over to my update function.
And we do know that this update function runs every single frame.
So over here in the bottom I'm going to check with right mouse button.
And later on we're gonna replace this with something like checkpoint.
Basically if we win the game then we can just trigger our victory UI.
For now I'm going to check with my right mouse button.
So I'm going to use this if condition.
Let's make first bracket and some curly brackets.
And what we want to check over here.
We basically want to check if input dot get mouse button down.
And we need to make these brackets.
And inside this bracket we need to pass 0 or 1.
So we're going to pass one.
One basically means the right mouse button.
So if input dot get mouse button down one basically means if we're clicking the left mouse button,
if that is the case then what we're going to call, we're going to call this trigger victory.
And it's going to do these things right over here as you can as you can notice, basically, we're doing
the same thing as we have done with that game over UI game or game over UI.
Now we're going to call the function here.
So let's call it trigger vector UI.
And let's make first bracket and some and close that up semicolon.
And we're going to press down Ctrl S to save our script.
And now let's move over to unity.
So you will see.
So as soon as we're going to right click the right click our mouse button.
You will see this page is just going to pop up in the y axis.
And it's going to be centered.
Since we pass zero F in the y basically means center.
And we don't.
And we we didn't mess around with the x or z axis.
So it's going to be fine.
So let's click on this play button in the top in order to play our game.
And let's take a look on this.
So as soon as we're going to click the right mouse button, it's going to pop up in the y axis to zero.
So just wait a moment.
So now.
If I right click, as you can see, as soon as we right click it just pop ups.
And if we click on this next button it's doing nothing.
So we're going to we're going to create a next button function for uh sorry.
Uh we're going to create a uh you can simply say a function for this next button.
So let's do that.
And we're going to do inside our scene management script.
Make sure you just click Get Out of play mode by clicking on that play button one more time.
And let's make a function for our next button.
To do so I'm going to open up my scene management script.
So I'm going to select my Scene Management GameObject in the hierarchy.
Let's go over to Inspector, then Scene Management Script.
And let's open that up by double clicking on it.
Uh, so we have the retry level and the menu uh function.
So let's make a one more function for our, uh, next button.
And we're going to make this function public since we're going to call this function through onClick
event.
So let's make a public, uh, void.
And we can call this function something like load next level something like that.
So let's let's call it load next level.
And let's make first bracket and some curly brackets.
So we don't have the next uh level right now.
So if the button is working fine or not we just want to check.
So for that we're going to print out a message uh, in the console, something like, uh, load next
level for testing purposes only.
So we're going to type debug dot log in order to print out our message.
And we're going to say something like in quotation load uh load load next level, something like that.
And let's, uh, let's close that up with semicolon.
And we're going to press down Ctrl s to save our script.
And now let's move over to unity.
So we need to hook that, uh hook that load next level function with our next button.
So we need to select our next button.
Uh, next button.
And we need to, uh, hook that function with our next button.
So just wait a moment.
So now it's done.
Uh, so I'm gonna move over to my hierarchy, then canvas, then victory ui, bg, and we're gonna choose
our next button.
Let's go over to Inspector, then scroll down to the button component and it's going to be something
like this.
So click on this plus icon.
And you need to drag the game object in which game object the script is sitting on.
And we do know we have done inside our scene management.
So basically if I choose my scene Management GameObject in the hierarchy, then go over to Inspector.
We can notice in management script is added to this scene management game object.
So we basically need to select our scene management scene management game object from our hierarchy.
Then drag it over to this right over here on click.
And as you can notice it says no function.
So let's click on it.
And we're going to move over to scene Management script.
Because this scene management inside this scene management game object the script is setting setting
setting which is our scene management script.
So that's why we're going to click on this no function.
And then we're going to move over to scene management script or scene Management C class.
And in there we created as you can notice which is load next level.
So I'm going to choose that function.
Now whenever we're going to click on this next button that load next level function.
Just going to call out and what that function is really doing.
It's basically printing out this message.
So it says load next level.
So now let's move over to unity and let's click on this play button in the top in order to play our
game.
And let's take a look on this.
So as soon as we're going to click on that next button, you will notice the message just going to pop
up underneath our console tab says Load Next Level.
So now if I just right click on it uh it's get pop up.
And if we just go ahead and then click on this next button.
As you can see, as soon as we're clicking on it underneath our console tab a message is getting pop
up.
Says load Next Level.
And if we click on this menu button it's not working at all.
So we need to hook this menu button with our menu function that we created inside our scene management
script.
So we're going to do that.
So let's get out of play mode.
And we're going to choose our menu button.
Let's go over to Inspector then button component in the bottom and a new game object.
So we're going to drag the game object there.
Let's go to no function then scene In manuscript or in scene management.
See shop class.
And we're going to choose this manual function for this menu button.
And make sure you go to Parent Game Object.
And then go over to Inspector Overrides and then apply all.
So the changes you made inside this factory UI, it's going to be saved into this factory UI prefab
as well.
And I'm going to clear my console tab and let's go over to the top.
So let's click on this play button in the top in order to play our game.
And let's have a look on this.
So so by now if we click the lab sorry.
If we click on that menu menu button then menu function just going to call out.
And we don't know what we're doing inside that menu function.
So I'm going to right click first and it's pop up.
And now if we click on this menu button, as you can see as soon as we're clicking on it underneath
our console tab a message screen pop up says Load menu.
So we don't have the scene yet.
We're going to create that later.
And if we click on this next button we can see load next label message just getting pop up.
So instead of printing out message we want to do something else.
So we basically want to load the next table.
And if we click on this menu button then we need to load up the menu scene.
Basically those are the things that we want.
So I hope you get the idea that how you can do it and I'm gonna get out of play mode.
So I hope you get the idea that how you can just make the victory UI, uh, from, uh, from scratch,
basically by duplicating from inside that prefab folder.
So some things we need to duplicate in the hierarchy, but some other things we need to duplicate from
that prefabs folder to make, uh, to maintain our project or to work a little bit faster.
So basically that is the thing.
So I hope you get the idea.
And now we're going to press down Ctrl s on our keyboard in order to save our project.