WEBVTT

00:00.080 --> 00:04.040
Let's say that active this game over UI through our code.

00:04.040 --> 00:05.280
So we're going to set that.

00:05.280 --> 00:08.160
So let's select our player GameObject in the hierarchy.

00:08.160 --> 00:11.640
And let's open up the player script quickly by double clicking on it.

00:12.240 --> 00:19.120
So what we basically need if we move over to unity underneath our canvas game object, we can see in

00:19.120 --> 00:21.560
the hierarchy we have game over UI.

00:21.600 --> 00:23.440
So we want this to be active.

00:23.440 --> 00:29.040
But when we shoot, once our player GameObject loses all of his health, then we're gonna active this

00:29.040 --> 00:30.160
game over here by.

00:30.240 --> 00:36.400
Basically, if we select our game over UI GameObject underneath our canvas, then move over to Inspector,

00:36.400 --> 00:37.240
we can check.

00:37.400 --> 00:40.200
Basically checking means we just activating that.

00:40.200 --> 00:46.400
And if we just uncheck, we mean we basically means we just deactivating that.

00:46.760 --> 00:52.200
So we need a reference of this game over UI GameObject, basically this whole game object.

00:52.200 --> 00:54.880
Then we can just set that to be activate.

00:54.880 --> 01:02.190
Or we just want to enable or disable depending upon if the player game object is alive or not.

01:02.390 --> 01:07.030
So let's select our player game object in the hierarchy, and we're gonna open up our player skip by

01:07.070 --> 01:08.390
double clicking on it.

01:08.710 --> 01:10.870
And let's go to top of our class.

01:11.910 --> 01:17.750
Uh, over here in the bottom I'm going to do uh, so let's make a serialized file.

01:17.750 --> 01:19.670
So let's make a serialized field.

01:20.470 --> 01:24.670
Serialized field, private private.

01:24.670 --> 01:28.710
And that came over by game object itself, a whole game object.

01:28.710 --> 01:33.950
So we're going to type game object, uh, the game object that we're looking for, basically that game

01:33.950 --> 01:37.150
over game object itself, a whole game object.

01:37.150 --> 01:40.710
So that's why we need to type the game object, uh, type.

01:40.950 --> 01:45.190
And we can simply call this one something like game over UI.

01:45.470 --> 01:47.030
And let's close that up.

01:47.070 --> 01:47.870
Semicolon.

01:47.870 --> 01:50.670
And I'm gonna press down Ctrl s to save our script.

01:50.670 --> 01:52.510
And let's move over to unity.

01:52.510 --> 01:56.950
So underneath our player we're gonna see another field just gonna appear.

01:57.070 --> 02:02.310
And by by default, we just named it Game Over UI.

02:07.390 --> 02:08.310
So just wait.

02:08.670 --> 02:14.910
So as soon as our player skip gates compile underneath our player skip in the bottom, we can see Game

02:14.950 --> 02:17.670
Over UI and it says none game object.

02:18.150 --> 02:24.110
So basically what we have to do over here we need to select our game over UI game object and drag it

02:24.110 --> 02:26.230
into that slot from the hierarchy.

02:26.390 --> 02:32.470
Now we can see we have the game over UI, game object prefab or the game object, and we are ready to

02:32.510 --> 02:34.390
activate or enable that.

02:34.390 --> 02:35.910
So let's open up our player.

02:35.910 --> 02:41.150
Skip quickly one more time, and we're going to scroll down to the bottom where we dying.

02:41.270 --> 02:45.830
So over here as you can see we're calling the type function and die function.

02:45.830 --> 02:52.550
Just doing the rest thing like setting is game active to false showing up explosion effect, all of

02:52.550 --> 02:53.430
these things.

02:53.430 --> 02:57.790
So we also want to activate that game over UI as well.

02:57.790 --> 03:03.820
So what we will do, we will go to Game Over UI and we're going to use this set active function.

03:03.820 --> 03:06.180
And this set active function in brackets.

03:06.180 --> 03:07.580
It's going to take the value.

03:07.580 --> 03:10.260
So if you just pass right over here true.

03:10.260 --> 03:16.020
So it's basically means that's gonna be activate right away means we are if we select our game over

03:16.060 --> 03:19.020
UI game object and check this in Inspector.

03:19.020 --> 03:22.180
So set active true basically means we're just activating.

03:22.220 --> 03:28.180
And if you just pass false means we just unchecking or deactivating our game over UI.

03:28.340 --> 03:30.980
But we do want we just want to activate.

03:30.980 --> 03:34.580
So that's why in these brackets I'm going to pass the true value.

03:34.580 --> 03:36.300
So we will pass true value.

03:36.300 --> 03:38.380
And let's close that up with semicolon.

03:38.620 --> 03:40.020
So I'm going to pass through.

03:40.060 --> 03:42.020
Let's close that up with semicolon.

03:42.020 --> 03:47.260
So basically what we're doing we're just going over to this game over UI game object in the hierarchy.

03:47.260 --> 03:48.060
We can see.

03:48.100 --> 03:54.580
And then we just activating or setting active to true means I just checking you can simply say and now

03:54.580 --> 03:57.410
we're going to press down Ctrl S to save our skin.

03:57.450 --> 03:59.130
Now let's move over to unity.

03:59.290 --> 04:05.610
So you will see, uh, as soon as our player GameObject loses all of his health, then we're calling

04:05.610 --> 04:06.610
the die function.

04:06.610 --> 04:12.490
And inside that die function, we just activating that game over UI and make sure you just drag the

04:12.490 --> 04:14.010
reference in your player.

04:14.010 --> 04:19.770
Skip, uh, have just take a look in Inspector, and we are ready to play our game.

04:19.770 --> 04:23.090
So let's click on this play button in the top to play our game.

04:23.090 --> 04:25.090
And let's have a look on this.

04:31.810 --> 04:37.610
So as soon as this player GameObject Conor loses all of his health, you will see this, uh, the game

04:37.610 --> 04:37.890
over.

04:37.930 --> 04:40.450
Just gonna activate right away.

04:40.450 --> 04:44.930
So just wait for it to, uh, take damage from this enemy GameObject.

04:44.930 --> 04:51.010
And we're going to take this, uh, take, uh, enemy uh, sorry damage from this enemy game object.

04:51.010 --> 04:52.090
So let's see.

04:52.970 --> 05:00.010
And we can see as soon as our player GameObject object as this game over us gets activate and if we

05:00.050 --> 05:04.410
click on this retry button, we can see this button doing nothing currently.

05:04.410 --> 05:07.450
So we need to hook this button with some certain function.

05:07.450 --> 05:09.250
So if I select my retry button.

05:09.250 --> 05:14.250
So if I move to hierarchy then game over UI game object underneath my canvas.

05:14.250 --> 05:16.210
And then select this retry button.

05:16.210 --> 05:17.810
Then move over to Inspector.

05:17.810 --> 05:18.770
Scroll down.

05:18.770 --> 05:22.850
We can see a button component is added to this button.

05:22.850 --> 05:24.170
This retry button.

05:24.170 --> 05:31.410
So over here what we're gonna do if we scroll down a bit we can see on click and it says list is empty.

05:31.450 --> 05:35.050
Basically we can just call a function over here as well.

05:35.410 --> 05:41.450
So as soon as we're gonna click this retry button and we're going to call a function over here.

05:41.650 --> 05:46.090
And inside that function we're going to do the thing that we really need to do.

05:46.290 --> 05:53.770
Uh, like uh, like loading up the levels in one more time so we can call the function on click basically

05:53.770 --> 05:56.920
underneath our button over here in the inspector.

05:56.960 --> 05:58.080
As you can see.

05:58.080 --> 05:59.760
So we can call a function.

05:59.760 --> 06:01.240
So let's get out of play mode.

06:01.240 --> 06:07.720
And we're going to create another script in order to uh, in order to click on that retry button.

06:07.720 --> 06:13.840
Basically as soon as we're gonna, uh, basically gonna click on that retry button, we just want to,

06:13.960 --> 06:15.960
uh, load up the level one more time.

06:15.960 --> 06:18.080
So we're going to create a script for that.

06:18.080 --> 06:22.480
So make sure you just go to Project App then assets and head over to Script Folder.

06:22.480 --> 06:27.960
Let's right click there then create and then Monobehaviour script and name that script to something

06:27.960 --> 06:29.600
like Scene Management.

06:29.640 --> 06:31.640
Don't name it to something like Scene Manager.

06:31.640 --> 06:33.360
Instead name it to something else.

06:33.360 --> 06:40.760
You can name it to scene management or you can say scene, uh, load or some something like that.

06:40.760 --> 06:43.120
So I already have created a scene manager.

06:43.120 --> 06:44.760
Screen scene manager.

06:44.840 --> 06:45.840
Uh, sorry.

06:45.880 --> 06:47.760
I just name it to scene manager.

06:47.760 --> 06:49.560
It should not be scene manager.

06:49.840 --> 06:55.110
And instead we're gonna create a scene management because it's gonna to give us an error.

06:55.110 --> 06:55.910
So that's why.

06:55.910 --> 06:58.590
So we're going to right click on this script folder one more time.

06:58.590 --> 07:01.230
Let's click go to create in the top.

07:01.230 --> 07:02.990
And then Monobehaviour script.

07:02.990 --> 07:07.510
And I'm going to name this script to something like Scene management not scene manager.

07:07.710 --> 07:10.270
Don't name it to scene manager, name it to something else.

07:10.270 --> 07:12.550
So I'm going to call it scene Management.

07:12.830 --> 07:14.310
And let's hit enter.

07:14.310 --> 07:18.350
And we're going to double click this script to open it up in Visual Studio.

07:18.910 --> 07:22.670
And we need to attach this script to our game object.

07:22.670 --> 07:28.430
So what I'm going to do I'm going to create a separate, uh, game object for this scene management

07:28.430 --> 07:29.190
script.

07:29.190 --> 07:32.030
And I'm going to attach this script to that game object.

07:32.030 --> 07:34.310
So just wait for to compile and run.

07:34.470 --> 07:37.150
Once you are done, we are ready to do that.

07:37.150 --> 07:38.310
So let's go to hierarchy.

07:38.310 --> 07:39.950
Right click or hit this plus icon.

07:39.950 --> 07:41.870
Let's create an empty game object.

07:41.870 --> 07:45.550
And I'm going to name this game object to as the name of our script.

07:45.550 --> 07:48.830
So I'm going to call it Scene Management.

07:49.630 --> 07:51.270
And let's go to transform.

07:51.270 --> 07:55.630
Right click and reset the transform and I'm going to select my scene management script.

07:55.630 --> 07:58.550
And let's drag it over to this Add Component section.

07:58.550 --> 08:04.390
And I'm going to drag my Scene Management GameObject in the top of my hierarchy so I can see all the

08:04.390 --> 08:04.910
time.

08:04.910 --> 08:08.310
And let's open up the scene management script by double clicking on it.

08:08.310 --> 08:11.790
And I'm gonna remove this update and start function we don't need.

08:12.110 --> 08:13.950
And we're going to work with scene.

08:13.950 --> 08:20.550
So make sure you, you just go to top of your class and include this namespace it call using Unity Engine,

08:20.710 --> 08:24.750
Unity engine, dot scene management, scene management.

08:24.750 --> 08:26.830
And then close that up with semicolon.

08:26.830 --> 08:33.910
So what we have to include this namespace in top of our class because we're gonna work with scenes or

08:34.070 --> 08:34.510
levels.

08:34.510 --> 08:39.110
So that's why we need to include this namespace in top of your class.

08:39.110 --> 08:40.830
So make sure you just do that.

08:41.150 --> 08:43.910
And we are ready to create our functions.

08:43.910 --> 08:45.430
So we're going to create two functions.

08:45.430 --> 08:49.390
One for just gonna just gonna be for this retry button.

08:49.390 --> 08:50.470
And the second button.

08:50.630 --> 08:54.140
Uh second one gonna for this retry button.

08:54.140 --> 08:57.340
And the second function we're gonna make for this menu button.

08:57.340 --> 09:01.420
So let's go to Skip now and make sure you make this function public.

09:01.420 --> 09:01.660
Why?

09:01.700 --> 09:04.500
Because we're going to call this function through our button.

09:04.540 --> 09:08.860
Basically whenever we're going to click on this button I just want to call this function.

09:08.860 --> 09:09.700
So that's why.

09:09.900 --> 09:11.940
So we're going to mark as a public function.

09:11.940 --> 09:13.980
And for function we're going to type void.

09:14.020 --> 09:19.380
And I'm going to name this function as something like retry button for my retry function.

09:19.380 --> 09:20.820
So I'm going to call it retry.

09:20.860 --> 09:21.500
Instead.

09:21.540 --> 09:24.420
Let's make first bracket and some curly brackets.

09:24.420 --> 09:28.860
And I'm going to put it for line space or from the left side.

09:29.540 --> 09:34.380
So what we want to do inside this function we just want to load up the scene.

09:34.380 --> 09:40.420
So in order to load up a scene or the level what you have to do, you need to include this function.

09:40.420 --> 09:46.100
It's called scene manager dot load scene function, load scene function.

09:46.100 --> 09:47.260
And we're not getting.

09:47.260 --> 09:53.370
So I'm gonna what I'm going to do, I'm going to move over to my unity because I already created a scene

09:53.370 --> 09:55.130
manager script, as you can see.

09:55.130 --> 09:56.490
So we need to delete that.

09:56.490 --> 09:59.130
So that's why it just not happening.

09:59.130 --> 10:02.290
So make sure you just select the scene manager and just delete.

10:02.330 --> 10:03.610
I don't name that.

10:03.730 --> 10:07.090
Uh, basically name a script something like scene management.

10:07.130 --> 10:09.650
Don't name it something like scene manager.

10:09.650 --> 10:10.490
So that's why.

10:10.530 --> 10:14.090
Or you can simply call level manager as well that script.

10:14.090 --> 10:16.850
So I have already created a scene manager script.

10:16.850 --> 10:22.970
And I'm going to delete that because I created a second script called Scene Management as you can see.

10:22.970 --> 10:27.650
So I'm going to select my scene manager script and I'm going to delete that because it just come are

10:28.050 --> 10:29.290
conflicting the error.

10:29.290 --> 10:33.570
So just right click that and then click on delete in the top you can see.

10:33.570 --> 10:34.530
So delete that.

10:34.530 --> 10:36.010
Now it should be fine.

10:36.210 --> 10:38.690
So make the script name scene management.

10:38.690 --> 10:40.250
Don't name it scene manager.

10:40.250 --> 10:42.250
And you can name it something else.

10:42.250 --> 10:43.330
And that is fine.

10:43.330 --> 10:47.410
Just don't name it something like Scene Manager because we need to use that function.

10:47.410 --> 10:48.410
Now it's done.

10:48.450 --> 10:53.850
If we move over to script Scrape, and in order to load up a scene, we need to use the scene manager

10:54.050 --> 10:55.610
dot load scene function.

10:55.610 --> 11:02.050
Now we can say and this function in brackets is going to take the same name in quotation or a.

11:02.410 --> 11:04.970
You need to pass the bill index of it.

11:04.970 --> 11:09.250
So how you can see the name of the scene and the built in build index of it.

11:09.250 --> 11:10.650
So move over to unity.

11:10.970 --> 11:13.970
In the hierarchy top you can see the name of the scene.

11:13.970 --> 11:20.250
We can see example scene, but we're not able to see the build index of it uh of the scene.

11:20.250 --> 11:25.090
So what you really have to do, you need, you need to move over to this top left file.

11:25.090 --> 11:28.090
So just click there and then click on this build profiles.

11:28.090 --> 11:35.250
In the bottom you can see and uh we and as soon as we uh, we're going to click on this open scene list.

11:35.250 --> 11:38.650
And now we can see the name of the scene is sample scene.

11:38.650 --> 11:39.570
And the build index.

11:39.570 --> 11:42.090
We can see in the right section which is zero.

11:42.090 --> 11:46.650
So you can uh, what you basically have to do, you will be windows or something like that.

11:46.650 --> 11:52.800
So just click on this open scene list and you can see the name of the scene as well as the index of

11:52.800 --> 11:53.160
it.

11:53.160 --> 11:58.120
So the name of the scene we can see in the left side, which is sample scene, and the index of it in

11:58.120 --> 11:59.760
the right section which is zero.

11:59.760 --> 12:03.200
So I'm going to cut this tab by now and let's move over to script.

12:03.320 --> 12:06.920
So in quotation what we simply do, what we simply can do.

12:06.960 --> 12:10.880
We can simply pass name of the scene which is sample.

12:11.120 --> 12:13.360
So sample scene.

12:13.400 --> 12:18.440
And let's close that up with semicolon or what you can simply do over here.

12:18.440 --> 12:21.640
You can simply pass the bill index without quotation.

12:21.960 --> 12:23.960
Uh so the index is zero.

12:23.960 --> 12:29.240
But I'm going to pass the name of the scene in my in quotation in between this quotation, which is

12:29.240 --> 12:30.080
sample scene.

12:30.080 --> 12:34.360
So I'm going to pass my sample scene and let's close that up with semicolon.

12:34.360 --> 12:36.080
And let's move over to unity.

12:36.080 --> 12:40.000
So this scene manager dot load scene function it's gonna load up the scene.

12:40.000 --> 12:43.000
And in brackets it's going to take the name of the scene.

12:43.000 --> 12:45.440
So we also need to call this retry button.

12:45.480 --> 12:48.200
Uh sorry retry function and retry function.

12:48.200 --> 12:51.240
Just going to do these things which are just going to load up the scene.

12:51.240 --> 12:53.040
So let's move over to unity.

12:53.040 --> 12:57.280
And I'm going to select my retry button underneath my game Over UI game object.

12:57.280 --> 12:58.440
Let's go to Inspector.

12:58.440 --> 13:03.360
Scroll down and scroll down to this button component.

13:03.360 --> 13:06.360
And in the on click and it says list is empty.

13:06.360 --> 13:09.400
So just click there and over here what you have to do.

13:09.440 --> 13:13.760
You need to drag the game object in which game object the script is attached.

13:13.760 --> 13:18.640
So in my case I attach the scene management script to this scene management game object.

13:18.640 --> 13:22.320
So I'm going to select that GameObject and drag it over to this slot.

13:22.320 --> 13:24.720
And it says no function as you can see.

13:24.720 --> 13:30.000
So just click there and we're going to move over to scene Management script or scene Management class

13:30.000 --> 13:31.040
as you can see.

13:31.080 --> 13:33.480
And we're going to call the retry function.

13:33.800 --> 13:39.440
So basically what we're doing we're just going over to this scene management and it says no function.

13:39.440 --> 13:40.560
So just click there.

13:40.560 --> 13:45.280
And we do no in that scene management game object the scene management script is attached.

13:45.280 --> 13:51.790
So that's why we are able to see the scene management class over here or the scene management screen.

13:52.070 --> 13:58.390
And uh, and we can see retry function as well as we created inside scene management script or scene

13:58.390 --> 13:59.950
management class.

13:59.950 --> 14:02.350
And we just made that retry function public.

14:02.350 --> 14:04.830
So that's why we are able to see over here.

14:04.830 --> 14:06.430
So I'm going to choose that function.

14:06.430 --> 14:13.270
So now if we just click on this retry button, as soon as we click on this retry button you will see

14:13.270 --> 14:15.310
that retry function just going to call.

14:15.310 --> 14:21.350
And what we what we have done in this retry function we just loading up the scene in which scene we

14:21.350 --> 14:22.670
are currently in.

14:23.350 --> 14:24.910
And let's go to unity now.

14:25.070 --> 14:28.870
And let's click on this play button in the top in order to play the game.

14:32.790 --> 14:35.630
So just wait for to compile and you're gonna see that.

14:36.070 --> 14:42.750
So as soon as we're gonna lose health, uh, a health app, basically after taking damage, you will

14:42.750 --> 14:45.670
see this player game object just gonna die right away.

14:45.830 --> 14:48.820
And after that, that came on, came over.

14:48.860 --> 14:50.700
You are just going to be activate.

14:50.740 --> 14:51.340
Activate.

14:51.340 --> 14:57.340
And we have two buttons or two option to do in in that game over.

14:58.180 --> 14:59.060
So just wait.

14:59.220 --> 15:06.180
And now if I just click on this retry button, as you can see, as soon as we click on that retry button,

15:06.180 --> 15:09.940
we just loading up the scene in which scene we are currently in.

15:09.980 --> 15:12.780
One more time we're going to get out of play mode.

15:12.780 --> 15:16.140
And instead of doing that, you can do that thing as well.

15:16.140 --> 15:21.820
So let's go to script instead of passing the name of the scene in quotation or the bill index of it,

15:21.820 --> 15:24.020
you can use these things as well.

15:24.020 --> 15:30.500
It's called scene manager, scene manager dot get active scene and make first packet.

15:30.500 --> 15:33.300
And then you have to use this build index.

15:33.300 --> 15:39.100
So what basically this means scene manager dot get active scene basically means the scene in which scene

15:39.100 --> 15:40.060
we are in.

15:40.060 --> 15:46.060
So if we move over to unity we can see in hierarchy we are in this sample scene.

15:46.060 --> 15:49.500
So the scene manager Dot get active scene right over here.

15:49.500 --> 15:51.220
Just going to be the sample scene.

15:51.220 --> 15:54.220
And then what we're doing, we're just accessing the build index.

15:54.220 --> 15:58.420
And we know the index of this of this sample scene is zero.

15:58.540 --> 16:02.900
So basically we're just loading up the scene in which scene we are currently in.

16:02.900 --> 16:07.740
So scene manager Dot get active scene basically means the scene we are currently in.

16:07.740 --> 16:10.380
So we are currently in this sample scene.

16:10.380 --> 16:16.900
So then what we're doing we just accessing the index of it means we just loading up the samples in one

16:16.900 --> 16:17.660
more time.

16:17.660 --> 16:22.780
So this scene manager Dot get active scene means the scene which we are currently in.

16:22.820 --> 16:30.460
And then we just accessing the index of it and we're just loading loading that up I'm really apologize.

16:30.540 --> 16:36.020
Uh, that bus just making noises I'm really apologize for it.

16:36.420 --> 16:39.780
So we're just loading up the scene, which scene we are currently in.

16:39.780 --> 16:43.620
So you can just pass this as well once you just retrying.

16:43.660 --> 16:45.850
So let's go to unity and let's have a look.

16:45.850 --> 16:49.650
So I'm going to press down Ctrl s on my keyboard to save my script.

16:49.650 --> 16:51.010
And let's go to unity.

16:51.010 --> 16:56.050
So once we're clicking on that retry button then what we're doing we're just moving over to this scene

16:56.050 --> 16:59.130
management game object and then scene management script.

16:59.130 --> 17:04.250
And then we're just calling the retry function once we click on that retry button.

17:04.250 --> 17:06.290
So let's go to unity one more time.

17:06.290 --> 17:11.050
And if I just click on this play button in the top, you will see as soon as we're going to click on

17:11.090 --> 17:17.890
that retry button, the the scene which we are currently in, it's going to load up one more time because

17:17.890 --> 17:19.290
we're calling that function.

17:19.290 --> 17:25.890
So just uh, let's wait to take damage from that enemy game object and you will see that.

17:25.890 --> 17:30.370
So just wait, uh, to take damage from this enemy game object.

17:33.370 --> 17:36.970
And now we're just taking damage from this enemy game object.

17:36.970 --> 17:38.370
And this seems fine.

17:38.370 --> 17:41.570
And now we can see game over UI just gets activate.

17:41.570 --> 17:46.200
And now if I just click on this retry button, that retry function just gonna call.

17:46.200 --> 17:50.000
And we do know what we have done inside that retry function.

17:50.000 --> 17:56.800
So if I just click on this, as you can see, as soon as we click the scene that we are currently in,

17:56.840 --> 17:59.120
we just loaded up that one more time.

17:59.120 --> 18:01.920
And you can see the name of the scene in hierarchy.

18:01.920 --> 18:07.120
Over here we can see the name of the scene is sample scene and the build index of it zero.

18:07.120 --> 18:08.680
So I'm going to get out of play mode.

18:08.680 --> 18:12.600
And now what we have to do if I just activate this game over UI.

18:12.800 --> 18:15.200
Now we need to work with this menu button.

18:15.200 --> 18:20.080
So once we click on this menu button I'm going to call the I'm gonna load up the menu scene.

18:20.080 --> 18:22.120
But we don't have the menu scene yet.

18:22.120 --> 18:26.960
So I just want to print out a message if it's working fine or not.

18:26.960 --> 18:32.080
So let's go to Scene Manager manuscript and I'm going to make a second function in the bottom.

18:32.080 --> 18:34.320
So let's make that function as well public.

18:34.320 --> 18:36.240
So we can call through a button.

18:36.360 --> 18:38.960
And for function we're going to type void.

18:39.000 --> 18:40.360
And we have to name the function.

18:40.360 --> 18:42.520
So I'm going to call it panel something like that.

18:42.600 --> 18:44.440
And let's make some curly brackets.

18:44.760 --> 18:50.080
And, uh, so we don't have the menu scene yet so we can load that up.

18:50.080 --> 18:52.640
So I'm going to print out a message instead.

18:52.640 --> 18:59.640
So printing out a message we're going to type Debug.log in order to print out message and make first

18:59.640 --> 19:00.000
bracket.

19:00.000 --> 19:05.600
And in quotation we're going to say something like load menu load menu.

19:05.600 --> 19:07.880
And let's close that up with semicolon.

19:07.880 --> 19:10.720
And we're going to press down Ctrl S to save our script.

19:10.720 --> 19:13.160
And I'm going to move this curly bracket over here.

19:13.320 --> 19:17.000
And let's press down one more time Ctrl s to save our script.

19:17.120 --> 19:22.440
And I'm going to hook this menu button or this sorry this menu function with our menu button.

19:22.440 --> 19:26.960
So as soon as we're going to click on that menu button we're going to call that menu function.

19:26.960 --> 19:32.520
And what menu function is doing is just printing out a message in the console says Load menu.

19:32.520 --> 19:33.320
So just wait.

19:33.320 --> 19:36.360
And once it's done we are ready to do that.

19:36.880 --> 19:41.560
So now we're going to select our menu button underneath our Game Over UI game object.

19:41.670 --> 19:43.070
So let's select the menu button.

19:43.350 --> 19:44.550
Let's go to Inspector.

19:44.550 --> 19:50.030
Scroll down to the bottom button component and we can see on click and it says list is empty.

19:50.030 --> 19:55.070
So let's click there and we're going to drag the game object in which game object the script is sitting

19:55.070 --> 19:56.270
on or attached.

19:56.270 --> 19:57.750
So in my case scene management.

19:57.750 --> 20:01.270
So let's drag right there and let's click on this no function.

20:01.270 --> 20:04.390
Let's go to scene management see class or Skip.

20:04.390 --> 20:08.310
And we can see the menu function over here because we made it public.

20:08.510 --> 20:10.550
And we're going to choose this menu function.

20:10.550 --> 20:17.030
Because once whenever we're going to click on this menu button we just want to call up call that menu

20:17.030 --> 20:17.590
function.

20:17.950 --> 20:18.390
So.

20:18.390 --> 20:23.790
So as soon as we click on this menu button you will see menu function just going to trigger or just

20:23.790 --> 20:24.550
going to call.

20:24.550 --> 20:29.590
And inside that menu function we just printing out a message in the console says load menu.

20:29.630 --> 20:30.790
As you can see.

20:31.070 --> 20:33.990
And make sure you just go to unity.

20:34.110 --> 20:37.630
And by default I'm gonna deactivate this game over UI.

20:37.670 --> 20:39.870
I don't want this to be activate.

20:39.870 --> 20:46.860
So let's uncheck in the inspector and let's click on this play button in the top to play our game.

20:47.020 --> 20:48.420
And let's have a look.

20:48.420 --> 20:53.780
So whenever as soon as we're going to click on that menu button you will see the message in the console.

20:53.780 --> 20:56.140
Just gonna pop up says Load Menu.

20:56.140 --> 20:58.580
So I'm going to select my console tab in the bottom.

20:58.860 --> 21:02.340
And let's take damage from that enemy game object.

21:02.340 --> 21:04.460
So just wait a little moment.

21:06.740 --> 21:10.700
And we're going to take damage from this enemy game object.

21:12.340 --> 21:14.900
So we're taking damage as you can see.

21:16.940 --> 21:18.660
And now the max is zero.

21:18.660 --> 21:21.700
So this game over UI just gets activated.

21:21.700 --> 21:28.100
And if I just go to click on this menu button, as you can see as soon as we click menu button, uh

21:28.140 --> 21:32.060
or basically click menu button, that menu function, just get call.

21:32.060 --> 21:37.660
And inside that menu function we are just printing out a message in the console we can see load menu.

21:37.660 --> 21:42.620
So as soon as we're going to click on this menu button, that menu function just calling.

21:42.660 --> 21:45.860
And we do know what we have done inside that menu function.

21:45.860 --> 21:50.980
We just printing out this message a load menu in the console as you can see.

21:50.980 --> 21:55.540
So I hope you get the idea that how you can call a function through a button.

21:55.540 --> 22:00.180
So basically you can call the function through a button by going over to button component.

22:00.180 --> 22:05.260
And you need to drag the game object in which game object the script is attached or sitting on.

22:05.300 --> 22:11.180
Then you can just call the function from that script in which script you have done all of these things.

22:11.420 --> 22:12.900
So I'm going to get out of play mode.

22:12.940 --> 22:18.540
I hope you get the idea that how you can do it, or how you can just print up, and we also need to

22:18.540 --> 22:21.820
create the scene as well in order to load that up.

22:22.140 --> 22:28.100
So I'm going to press down control S in my you can say keyboard to save my project.

22:28.100 --> 22:31.140
And I'm going to move over to my Game Over UI game object.

22:31.140 --> 22:32.220
Let's go to overrides.

22:32.220 --> 22:34.420
And I'm going to click on this Apply all.

22:34.580 --> 22:35.540
Now it's fine.

22:35.740 --> 22:39.700
And I'm going to press down one more time Ctrl S to save my project.
