WEBVTT

00:00.280 --> 00:01.880
And this exit button.

00:01.880 --> 00:08.280
So basically what we're gonna do, we're gonna use the scene management script, which we created earlier.

00:08.600 --> 00:13.120
So make sure you just move over to your levels in basically the sample scene.

00:13.160 --> 00:17.880
So firstly we will head over to Project App Assets and then since folder.

00:18.040 --> 00:24.720
And let's double click on this sample scene in order to move over to that scene or level and make sure

00:24.720 --> 00:30.800
you just go over to hierarchy and select your scene Management game object, and then turn it into a

00:30.800 --> 00:36.560
prefab so you will have the copy as well as we're gonna have this scene management script, since we're

00:36.560 --> 00:39.360
gonna do it inside this scene management script.

00:39.360 --> 00:40.960
So basically that is the thing.

00:41.240 --> 00:46.000
And once we just made it prefab, then we can just move over to our scene.

00:46.080 --> 00:48.120
So let's double click on on it.

00:48.120 --> 00:49.800
This scene or what.

00:49.840 --> 00:53.520
Simply you can do you can select any GameObject in the hierarchy.

00:53.640 --> 00:58.600
And you can select the Scene Manager script and then drag it over to that GameObject.

00:58.600 --> 01:01.440
And after that you can just do the scripting.

01:01.720 --> 01:03.380
So basically the same thing.

01:03.740 --> 01:10.100
Uh, but I already have the sim management game object, so I'm gonna drag my sim management game object

01:10.100 --> 01:12.980
in the hierarchy inside my nano sim.

01:13.020 --> 01:19.340
To do so, let's head over to Project Assets and then prefabs folder, and I'm gonna select this scene

01:19.340 --> 01:23.580
Management game object from this inside this prefabs folder.

01:23.580 --> 01:27.140
And let's drag it over to hierarchy or into this scene view.

01:27.140 --> 01:30.140
So I'm going to drag it over to my hierarchy.

01:30.380 --> 01:31.900
And now what we need to do.

01:31.980 --> 01:36.300
We need to hook this play button with this scene management uh script.

01:36.300 --> 01:42.460
Basically we're going to create a function for this play uh play button.

01:42.460 --> 01:47.820
So whenever we're going to click on this play button, then we just want to play our game.

01:47.820 --> 01:54.860
So we're gonna make a function for our play button as well as for this exit button to do some, uh,

01:54.900 --> 01:59.860
things like once we're gonna click on this play button, then we want to play our game.

01:59.860 --> 02:06.200
And once we click on this exit button, then we want to exit our application or the game?

02:06.480 --> 02:10.360
So let's open up our scene management script by double clicking on it.

02:10.520 --> 02:12.560
And let's make two function.

02:12.680 --> 02:15.080
So I'm going to move over to top of my class.

02:15.080 --> 02:17.280
And you can do it anywhere.

02:17.280 --> 02:19.240
It doesn't need to be in order.

02:19.240 --> 02:21.600
And make sure you make this function public.

02:21.600 --> 02:24.600
So we can call this function through our button.

02:24.880 --> 02:28.240
So firstly I'm going to create a function for my play button.

02:28.240 --> 02:31.240
So let's make public uh public.

02:31.240 --> 02:35.280
So make sure you make it public so we can call the function on click.

02:35.480 --> 02:39.640
So whenever we're going to click on that play button then we want to call the function.

02:39.640 --> 02:43.160
So that's why we're just marking this function as public.

02:43.160 --> 02:45.280
And for function we're going to type void.

02:45.280 --> 02:46.760
And we have to name the function.

02:46.760 --> 02:50.600
So I'm going to call it play uh game something like that.

02:50.600 --> 02:53.560
Let's make first bracket and some curly brackets.

02:53.840 --> 02:56.000
And whenever you're working with scene.

02:56.000 --> 03:02.920
So make sure you just go to top of your class and include this namespace called using Unityengine Scene

03:02.920 --> 03:03.480
management.

03:03.480 --> 03:06.080
So make sure that is it.

03:06.150 --> 03:12.510
a basically, it exists in our script already, so make sure you just include that.

03:12.710 --> 03:17.950
Uh, so what we want to do inside this play game function, we want to play our game.

03:17.950 --> 03:21.310
So we need to load up our sample scene or the level scene.

03:21.670 --> 03:29.510
So we're going to use this scene manager uh scene manager dot load scene function dot load scene function.

03:29.670 --> 03:31.430
And this function in brackets.

03:31.470 --> 03:35.150
It's going to take the scene and name scene name in quotation.

03:35.150 --> 03:39.350
Or you can simply, uh, basically pass the bill index of it.

03:39.350 --> 03:46.310
So if we move over to unity and go, uh, and move over to hierarchy, we can see the name of the scene

03:46.310 --> 03:47.390
is a Manu.

03:47.590 --> 03:52.110
And if we move over to our project tab assets and then prefabs folder.

03:52.150 --> 03:52.630
Sorry.

03:52.910 --> 03:58.750
Uh, since folder we can see the sample scene right over here we have is the level scene.

03:58.750 --> 04:02.150
Basically we're just playing our game inside this sample scene.

04:02.150 --> 04:04.070
So if I just double click on it.

04:04.070 --> 04:05.710
So I'm going to click on this save button.

04:05.710 --> 04:09.850
So whatever I have done inside this magazine, it's going to be safe.

04:09.850 --> 04:11.690
So I'm going to click on this button.

04:11.690 --> 04:19.090
And as soon as we click on that save button, we can we just move it over to our sample scene or the

04:19.130 --> 04:24.930
low level so we can see the name of the scene in hierarchy right over here in the top.

04:24.970 --> 04:28.890
And the name of the scene is sample scene or what else you can do.

04:28.930 --> 04:31.970
You can see the name as well in your build profile.

04:32.090 --> 04:36.570
For that, you basically need to move over to the top left file, then click.

04:37.210 --> 04:42.810
Then click on this build profiles in the bottom and you can see the name of the scene.

04:42.810 --> 04:44.610
So you will be scene list.

04:45.050 --> 04:47.810
Labs are basically left side.

04:47.810 --> 04:50.650
We can see windows and it says active.

04:50.650 --> 04:53.130
And we're going to click on this open scene list.

04:53.130 --> 04:56.010
And we can see the name of the scene is Sample Scene.

04:56.010 --> 04:59.490
But we don't have the scene inside our scene list.

04:59.490 --> 05:00.970
So we're going to drag that.

05:00.970 --> 05:05.930
So going to select our scene that scene from that scenes folder.

05:05.930 --> 05:08.810
And let's drag it over to this scenes list.

05:08.930 --> 05:13.750
And we're going to drag this piano scene in the top, because this one should be the default one.

05:13.750 --> 05:20.910
So whenever our player just gonna open our game, this menu should load up right away or so.

05:20.910 --> 05:23.030
That's why we just drag it in the top.

05:23.190 --> 05:27.590
And now we can see the name of the scene is Sample scene and the build index.

05:27.590 --> 05:30.550
We can notice in the right section which is one.

05:30.550 --> 05:33.710
So we can simply pass the build index of it.

05:33.710 --> 05:38.470
Or we can simply pass the name of the scene which is sample scene in quotation.

05:38.470 --> 05:40.990
So it's basically up to you what you want to do.

05:41.030 --> 05:42.830
So I'm going to cut this tab by now.

05:42.910 --> 05:44.950
Let's move over to our script.

05:44.950 --> 05:47.870
And over here it's going to take the name of the scene.

05:47.870 --> 05:54.310
So we can pass in quotation the name of the scene which is sample scene.

05:54.630 --> 05:58.390
Or you can just, uh, what you can what else you can do.

05:58.430 --> 06:04.150
You can just remove this, uh, name of the scene or, and you can simply pass the bill index of it,

06:04.190 --> 06:07.790
which is one, and make sure you just close that off with semicolon.

06:07.790 --> 06:12.130
But instead of passing the name of the, uh, sorry, build index of it.

06:12.130 --> 06:14.090
I'm going to pass the name of the scene.

06:14.290 --> 06:18.770
It doesn't need to be, but it's basically up to you what you want to do.

06:18.770 --> 06:24.570
So make sure you type quotation first and then pass the name of the scene, which is sample scene and

06:24.570 --> 06:28.570
make sure you spelling it correct, else it's not going to work at all.

06:29.210 --> 06:33.810
So I'm going to press control S on my keyboard in order to save my script.

06:33.810 --> 06:35.770
And now let's move over to unity.

06:36.290 --> 06:39.370
So firstly we need to move over to scene.

06:39.610 --> 06:44.690
And we need to hook that play button play button with our play game function.

06:44.690 --> 06:51.610
So just wait a moment and once our compilation is done, we can just go ahead and we can do that thing

06:51.610 --> 06:52.530
in order.

06:52.570 --> 06:54.890
A basically we can do that thing.

06:54.890 --> 06:56.130
So just wait a moment.

06:56.810 --> 07:01.930
Uh, firstly, we are just going to move over to our panel scene and we're going to hook that play button

07:01.930 --> 07:03.890
with our play game function.

07:04.410 --> 07:06.090
So just wait a moment.

07:10.210 --> 07:13.050
So now I'm gonna double click on this scene.

07:13.150 --> 07:17.590
Firstly, I'm gonna move over to my project tab assets and then scenes folder.

07:17.790 --> 07:24.550
And let's double click on this scene and move over to inside basically and move over to this panel scene.

07:24.870 --> 07:29.990
And now what we're gonna do, we're gonna move over to Hierarchy Canvas, and then we're going to select

07:29.990 --> 07:31.190
our main panel.

07:31.310 --> 07:32.950
And let's select this BG.

07:32.990 --> 07:35.390
And then we're gonna select our play button.

07:35.390 --> 07:40.110
And if we go over to Inspector then scroll to down to the button component.

07:40.230 --> 07:42.630
We can call the function over here.

07:42.630 --> 07:44.630
So let's click on this plus icon.

07:44.630 --> 07:49.270
And we need to drag the GameObject in which GameObject the script is sitting on.

07:49.270 --> 07:55.030
So if I move over to hierarchy, the script is sitting on inside the Scene Management GameObject.

07:55.030 --> 07:57.190
As you can notice in Inspector.

07:57.190 --> 07:59.070
So I'm gonna select my play button.

07:59.070 --> 08:01.790
And then we're gonna scroll down to the button component.

08:01.790 --> 08:08.070
And we need to drag the GameObject in which GameObject the script is attached, in which GameObject

08:08.070 --> 08:10.110
the script is already attached.

08:10.310 --> 08:11.870
So in my case Scene management.

08:11.870 --> 08:16.620
So I'm gonna drag that into that slot and it says no function.

08:16.620 --> 08:18.260
So let's click on it.

08:18.260 --> 08:23.900
And then we can see in the bottom we have the scene management script or scene management C-sharp class.

08:24.060 --> 08:29.020
And inside that scene management script we created the play game function.

08:29.020 --> 08:30.900
And we can notice right over here.

08:30.900 --> 08:32.220
So we're going to choose that.

08:32.220 --> 08:37.260
So now as soon as we're going to click on this play button that function just gonna trigger.

08:37.460 --> 08:42.700
And what this function is really doing it's just loading up the scene, which is uh, we can see the

08:42.700 --> 08:46.740
name of the scene inside quotation, which is sample scene.

08:46.780 --> 08:49.500
Or you can simply pass the build index of it.

08:49.500 --> 08:55.060
And now what we're going to do, let's click on this play button in the top in order to test it.

08:55.060 --> 09:01.660
So whenever we click on this play button you will be able to notice that we're just gonna move over

09:01.660 --> 09:05.340
to sample scene or in which scene we just playing our game.

09:06.660 --> 09:08.060
So just wait a moment.

09:08.060 --> 09:11.500
And if I just click on this play button, uh play button.

09:11.500 --> 09:12.700
So just wait a moment.

09:12.700 --> 09:19.200
So as you can see, as soon as we clicked on that play button, We just move it over to our sample scene.

09:19.200 --> 09:21.680
And you can notice in your hierarchy tab.

09:21.680 --> 09:27.080
So if we move over to hierarchy tab we can see the name of the scene is Sample scene.

09:27.360 --> 09:33.320
And if we try something like this uh, we get a pop up.

09:33.840 --> 09:34.320
Sorry.

09:34.360 --> 09:36.080
We're gonna get a pop up.

09:38.120 --> 09:42.560
Uh, I don't know what's happening, so we cannot say.

09:42.560 --> 09:43.960
Just wait a moment.

09:43.960 --> 09:46.160
So let's leave it for that.

09:46.160 --> 09:51.960
And now let's talk about this exit button, and we're gonna talk a we're gonna take a look on that back

09:52.000 --> 09:52.640
later.

09:52.640 --> 09:56.960
So, uh, wait for some moments and we're going to do that.

09:57.120 --> 10:01.280
Uh, so what we're going to do now, we're gonna talk about this exit button.

10:01.280 --> 10:05.120
So we need to hook this exit button with our exit function.

10:05.120 --> 10:12.160
To do so, we're going to move over to our script and let's make a exit a game function for our exit

10:12.160 --> 10:12.640
button.

10:12.840 --> 10:14.840
And I'm going to do it in the bottom.

10:14.880 --> 10:17.560
It doesn't need to be in order as well.

10:17.680 --> 10:25.140
Uh, like I have, uh, I have already told multiple times, and I really apologize for it.

10:25.500 --> 10:31.660
So for function we're going to type, uh, so for for function we're going to type void and make sure

10:31.660 --> 10:34.620
you make this function, uh public as well.

10:34.860 --> 10:38.220
And we're going to call this function to something like exit game.

10:38.300 --> 10:41.140
Let's make first bracket and some curly brackets.

10:41.140 --> 10:48.220
And we do know that, uh, we in order to quit our application we need to use this application.

10:48.420 --> 10:50.180
So we need to use this function.

10:50.180 --> 10:51.820
It's called application.

10:52.100 --> 10:53.420
Application.

10:53.700 --> 10:54.820
Application.

10:54.860 --> 10:55.340
Sorry.

10:56.900 --> 11:00.860
It's application dot quit function.

11:01.260 --> 11:02.380
Quit function.

11:02.380 --> 11:06.340
And then make this first bracket and then close that up with semicolon.

11:06.460 --> 11:14.180
And we do know that uh, in unity editor, it's not going to exit or quit our application or the game.

11:14.180 --> 11:19.580
But we do know that once we're going to make the game completely, and then if we click on this exit

11:19.580 --> 11:22.600
button, then it's gonna quit our game right away.

11:22.800 --> 11:27.720
So in order to test, uh, purposes, we're gonna print out a message.

11:27.720 --> 11:31.680
So if we click on this exit button, we're going to say something like exit.

11:31.840 --> 11:32.720
And we just.

11:32.760 --> 11:38.840
And make sure you put this line of code which is application dot quit in order to quit your application.

11:39.040 --> 11:42.960
And in unity editor, it's not going to happen at all.

11:42.960 --> 11:50.560
So for testing purposes, uh, basically to check that exit game exit button is working or not, we're

11:50.560 --> 11:52.240
going to print out a message.

11:52.400 --> 11:58.760
So for printing out we're going to type this debug.log and we're going to say something like exit game

11:58.760 --> 11:59.760
in quotation.

11:59.760 --> 12:01.760
So let's say exit game.

12:02.160 --> 12:04.840
And then let's close that up with semicolon.

12:04.840 --> 12:06.120
And we're going to press down.

12:08.040 --> 12:10.680
Really sorry I really apologize for this.

12:10.800 --> 12:13.800
And we're gonna press Ctrl s to save our script.

12:13.800 --> 12:16.520
And now let's move over to Unity editor.

12:16.720 --> 12:21.400
So we need to hook this exit button with our exit exit function.

12:21.400 --> 12:25.860
Exit game function, and we do know what we're doing inside that function.

12:25.860 --> 12:29.220
We basically printing out the message says exit game.

12:29.220 --> 12:33.540
So we need to hook this exit button with our exit function.

12:34.060 --> 12:36.060
So I'm gonna choose my exit button.

12:36.260 --> 12:41.540
Uh underneath my BG, inside this main menu, underneath my canvas in the hierarchy.

12:41.740 --> 12:45.740
Let's go over to Inspector and scroll down to the button component.

12:45.740 --> 12:48.060
And we can call the function over here.

12:48.060 --> 12:52.180
So let's click on this plus icon in order to call the function.

12:52.180 --> 12:56.660
And we need to drag the game object in which game object the script is sitting on.

12:56.660 --> 12:58.740
So we're going to select our scene management.

12:58.740 --> 13:01.620
Let's drag it there and it says no function.

13:01.620 --> 13:02.820
So let's click on it.

13:02.820 --> 13:04.700
Let's go over to scene management.

13:04.900 --> 13:10.860
And we're gonna choose our exit game function for this exit button as you can notice.

13:10.860 --> 13:17.500
So whenever we click on this exit exit button then exit game function just gonna call out.

13:17.500 --> 13:20.500
And we do know what we're doing inside that function.

13:20.500 --> 13:22.980
So let's click on this play button in the top.

13:22.980 --> 13:26.810
And I'm going to select my console tab in order to check that out.

13:30.410 --> 13:34.850
So just wait a moment and once we are done we can check that out.

13:34.850 --> 13:36.130
So just wait a moment.

13:38.010 --> 13:43.690
So now if we just select our console tab and then click on this exit button.

13:43.690 --> 13:49.570
As you can see, as soon as we're clicking on that exit button, the message just getting pop up in

13:49.570 --> 13:52.010
our console tab says Exit Game.

13:52.050 --> 14:00.410
But we can notice that we are not quitting our game at all in unity Editor or we not exiting out from

14:00.450 --> 14:02.090
this, uh, game.

14:02.450 --> 14:04.170
So basically that is the thing.

14:04.330 --> 14:11.170
And once you make the application completely basically your game, and then if you just go ahead and

14:11.170 --> 14:17.450
then click on this exit button, then it's gonna quit your application or the game right away.

14:17.690 --> 14:20.850
Uh, or it's gonna exit your game right away.

14:20.890 --> 14:22.690
So I hope you get the idea.

14:22.930 --> 14:27.630
And if we click on this about panel, we just moving over to about menu section.

14:27.630 --> 14:33.310
And if we click on this back button we can notice we can just moving over to our main panel.

14:33.470 --> 14:37.510
And if we click on this play button then we just playing our game.

14:37.670 --> 14:44.190
So basically we just loading the samples in and we're gonna take a look on that back later.

14:44.190 --> 14:46.630
So let's take a look on this now.

14:47.390 --> 14:49.790
So it's basically working fine.

14:50.350 --> 14:52.070
So it's fine.

14:52.070 --> 14:53.790
So I'm gonna get out of play mode.

14:53.950 --> 14:56.430
And we're gonna talk about the bug later.

14:56.590 --> 14:59.750
So I hope you get the idea that how you can make it.

14:59.750 --> 15:03.590
And now we're going to press control S to save our project.

15:03.590 --> 15:06.990
But before you do, make sure you select your main menu.

15:06.990 --> 15:10.670
Basically the changes we have done inside this main menu.

15:10.790 --> 15:12.750
So make sure you select that.

15:12.790 --> 15:16.550
Then go over to Inspector, then over it and then apply all.

15:16.550 --> 15:22.710
So the changes we made over here, it's going to be saved into this main banner prefab game object as

15:22.710 --> 15:23.190
well.

15:23.230 --> 15:27.990
Or copy of this main panel UI or this main panel game object.
