WEBVTT

00:00.020 --> 00:00.470
Hello guys.

00:00.470 --> 00:01.430
Welcome to the video.

00:01.430 --> 00:04.580
So in this one I want to finalize the UI.

00:04.580 --> 00:07.760
We have I mean main menu and how buttons are working here.

00:07.760 --> 00:08.780
We have a couple of options.

00:08.780 --> 00:10.850
But overall it's all very simple.

00:10.850 --> 00:16.460
We need to decide how are we going to do for example, new game difficulty, skin selection, level

00:16.460 --> 00:23.960
selection or new game skin selection difficulty selection level selection order here is not very important.

00:23.960 --> 00:27.200
So yeah, let's just do something here.

00:27.380 --> 00:28.070
Uh, continue.

00:28.070 --> 00:30.260
Button is already working as we need.

00:30.260 --> 00:32.270
It just goes and chooses the.

00:34.210 --> 00:35.260
The.

00:37.500 --> 00:38.730
The level you should play.

00:38.730 --> 00:39.330
I'm sorry.

00:39.330 --> 00:40.560
I don't know what happened.

00:40.650 --> 00:45.960
The only issue we need to fix is that you're supposed to continue on the same difficulty you had when

00:45.960 --> 00:48.480
you left the game, so that's what we need to do.

00:48.690 --> 00:49.470
All right.

00:49.470 --> 00:51.300
We're going to take care of that in the end.

00:51.300 --> 00:54.420
As of now let's go to new game button.

00:54.420 --> 00:57.060
And new game will switch us to.

00:58.010 --> 01:00.140
Now, let's say difficulty selection.

01:00.870 --> 01:02.910
Then on the difficulty selection.

01:02.910 --> 01:05.460
Once we choose the difficulty.

01:05.490 --> 01:08.520
Next step would be to switch to skin selection.

01:08.520 --> 01:11.520
So I'm going to select this three buttons.

01:11.520 --> 01:16.260
And over here instead of going to the new game we're going to do UI.

01:16.440 --> 01:17.670
Switch UI.

01:17.670 --> 01:21.240
And as a UI we want to switch to it's going to be skin selection.

01:21.660 --> 01:26.070
Then on the skin selection we have button select.

01:26.070 --> 01:27.720
It will select the skin.

01:29.020 --> 01:36.640
And we also want to go to next UI, but only if we select the skin, not if we buy it.

01:36.640 --> 01:40.360
So probably we need to go to US skin selection.

01:40.690 --> 01:43.600
And over here we need to make a method.

01:45.420 --> 01:48.780
Or better, we can get a reference to the.

01:49.790 --> 01:54.230
Now level selection and just enable level selection through UI.

01:54.230 --> 01:55.010
Main menu.

01:57.340 --> 01:59.530
So how are we going to do this?

01:59.830 --> 02:02.830
We have this method switch UI and it's public.

02:02.830 --> 02:06.880
So on the skin selection we can do private.

02:08.930 --> 02:10.970
UI level selection.

02:11.120 --> 02:13.610
Level selection UI.

02:13.730 --> 02:16.460
And we need private UI.

02:16.490 --> 02:17.480
Main menu.

02:17.510 --> 02:18.920
Main menu UI.

02:19.370 --> 02:27.320
Now in the start we're going to do main menu UI equals to get component in parent of UI.

02:27.320 --> 02:28.160
Main menu.

02:30.060 --> 02:35.550
And then we need to get level selection UI, but it is not apparent and if we don't want to assign it

02:35.550 --> 02:37.530
manually, we can do something like this.

02:37.560 --> 02:41.790
Level selection UI equals to main menu UI.

02:41.790 --> 02:45.840
Get component in children of UI level selection.

02:45.840 --> 02:47.160
This is how it will be.

02:47.340 --> 02:48.870
And then.

02:49.650 --> 02:55.290
On the select skin over here only if we select in the skin, we're going to do.

02:55.980 --> 02:56.490
Um.

02:57.770 --> 02:59.240
Main menu UI.

02:59.270 --> 03:00.770
Switch UI.

03:01.130 --> 03:02.870
Level selection UI.

03:05.960 --> 03:10.310
And actually I just realized it should be GameObject variable over here.

03:10.430 --> 03:11.600
Or we can do in opposite.

03:11.600 --> 03:15.650
We can just go here and do dot GameObject.

03:16.100 --> 03:18.500
Okay, now let's save this.

03:18.500 --> 03:19.640
Let's go back.

03:23.890 --> 03:30.670
We don't need to change anything on, uh, this select button, because we're doing it in the script.

03:30.670 --> 03:33.400
And this will switch us to level selection.

03:33.400 --> 03:36.970
And then on the level selection we're going to have buttons that will run the level.

03:36.970 --> 03:39.460
So basically it's all ready to go.

03:39.460 --> 03:40.780
Let's try this.

03:42.590 --> 03:43.760
I have a new game.

03:43.760 --> 03:44.330
I'm going to click.

03:44.330 --> 03:45.380
New game.

03:45.380 --> 03:47.240
I want to choose difficulty.

03:47.950 --> 03:48.670
And.

03:48.670 --> 03:49.480
Okay.

03:49.690 --> 03:50.740
This is good, I found it.

03:50.740 --> 03:51.700
Let's fix it.

03:51.700 --> 03:53.650
We need to go to main menu.

03:53.650 --> 03:53.980
No.

03:53.980 --> 03:54.340
Sorry.

03:54.340 --> 03:55.150
Canvas.

03:56.370 --> 03:58.680
And we need to add other UI here.

03:58.680 --> 04:00.420
So difficulty goes here.

04:00.420 --> 04:02.220
And do we have anything else?

04:05.180 --> 04:07.400
12345.

04:09.410 --> 04:09.710
Okay.

04:09.710 --> 04:10.460
This should be good.

04:10.460 --> 04:11.720
Let me try again.

04:13.490 --> 04:15.950
New game normal.

04:15.950 --> 04:17.540
Select the skin.

04:18.020 --> 04:21.110
I want to purchase this one, then I want to select it.

04:21.660 --> 04:24.450
And we have a error.

04:26.900 --> 04:28.040
Level selection UI.

04:28.070 --> 04:30.110
I guess we did not get the component.

04:30.500 --> 04:31.400
Why not?

04:32.480 --> 04:33.230
Why not?

04:33.230 --> 04:33.980
Why not?

04:34.010 --> 04:35.540
There is a level selection UI.

04:35.540 --> 04:37.220
It is a child of a canvas.

04:37.220 --> 04:38.000
So.

04:38.000 --> 04:40.460
Oh man, I know why I'm here.

04:40.550 --> 04:41.930
I got it, okay?

04:41.930 --> 04:43.340
It's good, I got it.

04:43.340 --> 04:45.770
All right, so this is what is happening now.

04:45.770 --> 04:47.720
Let me go to skin selection.

04:47.990 --> 04:53.480
We can switch it back to what it was with, um, main menu UI over here.

04:53.480 --> 04:53.960
Becsehely.

04:53.960 --> 04:55.130
Basically, it's the same thing.

04:55.130 --> 04:56.750
Doesn't matter, but let's switch it back.

04:56.750 --> 04:57.830
So what happens here?

04:57.830 --> 04:59.180
We're getting component.

04:59.180 --> 05:04.940
And if component is disabled, if GameObject is disabled you will not be able to get it like that.

05:04.940 --> 05:07.400
You actually need to type true over here.

05:07.400 --> 05:11.270
So it will consider disabled gameobjects as well.

05:11.270 --> 05:15.530
And now if we do it like that, it's going to work all right.

05:16.970 --> 05:17.600
Pretty nice.

05:17.600 --> 05:18.980
I completely forgot about this.

05:18.980 --> 05:19.910
Can you imagine?

05:20.000 --> 05:21.530
Let's go to play mode now.

05:23.170 --> 05:24.370
New game.

05:24.370 --> 05:25.630
Normal.

05:25.840 --> 05:28.060
Uh, let's select this skin.

05:28.060 --> 05:30.340
We are on the level selection.

05:30.430 --> 05:32.350
I'm going to click level two and boom!

05:32.350 --> 05:36.490
We are in the game and I can play and enjoy the game.

05:36.490 --> 05:39.190
And difficulty is normal okay.

05:39.190 --> 05:43.330
The only goal is now to pass last difficulty.

05:43.330 --> 05:50.260
We used to continue button because as of now if I click continue I'm going to be playing easy mode.

05:50.260 --> 05:51.400
That's a bug.

05:52.010 --> 05:53.780
Now over here on difficulty.

05:53.780 --> 05:54.530
Manager.

05:54.530 --> 06:00.560
We're supposed to be able to choose difficulty with the integer, because we can save only a float int

06:00.560 --> 06:01.520
and string.

06:01.520 --> 06:05.330
We want to save int to know the difficulty index.

06:05.330 --> 06:07.880
And then we can just set it with a method.

06:07.880 --> 06:16.040
So how it's going to be we have this as easy at zero, normal at one and hard at two.

06:16.370 --> 06:19.010
But if you would like you can start count from one.

06:19.010 --> 06:25.010
For example you can do equals to one here and now this will be one, two, three.

06:25.010 --> 06:29.960
So just as a you know like different example, let's try to start from one.

06:29.960 --> 06:30.740
Why not.

06:31.800 --> 06:34.530
Because zero calendar says like we have none.

06:34.620 --> 06:36.180
So we cannot use zero, one, two.

06:36.180 --> 06:39.540
I guess that would not be very logical in my opinion.

06:40.640 --> 06:41.090
So.

06:41.090 --> 06:41.480
Yeah.

06:41.720 --> 06:43.070
Uh, when we.

06:45.120 --> 06:52.170
When we go into the game from a level button over here, we want to save the difficulty.

06:52.200 --> 06:56.130
You mean exactly when we choosing the level only then.

06:56.130 --> 07:01.200
Because if we choose difficulty in the middle of the UI, then go back, then it can forget what difficulty

07:01.200 --> 07:01.800
was there.

07:01.800 --> 07:04.890
So I guess it's better to do it here on a load level.

07:04.890 --> 07:07.800
So you're going to do Playerprefs set int.

07:09.600 --> 07:12.240
Game difficulty.

07:12.660 --> 07:20.280
And here we just need to take enum from a difficulty manager and turn it into integer so we can do.

07:21.000 --> 07:25.500
Int difficulty index equals to difficulty manager.

07:27.080 --> 07:29.120
Dot instance dot difficulty.

07:29.120 --> 07:33.380
And then we just type.int and it will convert it to integer.

07:33.380 --> 07:36.200
And we can pass it here difficulty index.

07:36.500 --> 07:37.370
Very nice.

07:37.370 --> 07:40.340
Now let's just copy this line of code.

07:40.490 --> 07:43.130
Let's go to the main menu.

07:43.700 --> 07:46.850
Over here we have continue game.

07:47.520 --> 07:48.930
And I'm just going to.

07:49.970 --> 07:51.680
Do int.

07:52.430 --> 07:55.940
Difficulty index equals to Playerprefs.

07:56.390 --> 07:58.580
Get integer.

07:59.200 --> 08:00.880
And we're not going to pass default value.

08:00.880 --> 08:06.700
I think a better let's pass one just in case, you know, just in case.

08:06.970 --> 08:07.450
Okay.

08:07.450 --> 08:14.140
And then before we, uh, load the level we want to call method on a difficulty manager, give it an

08:14.140 --> 08:16.960
index and that will choose difficulty for us.

08:17.260 --> 08:18.850
So let's go here.

08:19.990 --> 08:23.140
Let's do public void load difficulty.

08:23.650 --> 08:26.530
We're going to pass int difficulty index.

08:26.530 --> 08:31.090
And then over here I'm going to do difficulty equals to.

08:31.750 --> 08:38.110
And we're going to type and we're going to open parentheses type difficulty type and then difficulty

08:38.110 --> 08:39.580
index like that.

08:39.580 --> 08:47.380
And it's going to switch it uh over here it's going to choose the enum by the number over here okay.

08:47.380 --> 08:50.350
So it's sort of like converting it back okay.

08:50.350 --> 08:51.190
So we have a method.

08:51.190 --> 08:53.500
Now we can go to level button.

08:54.220 --> 08:54.850
Oh sorry.

08:54.850 --> 08:55.720
Main menu.

08:55.720 --> 08:57.400
Continue game over here.

08:57.400 --> 09:00.130
And then we're going to do difficulty manager.

09:00.430 --> 09:05.080
Difficulty manager dot instance dot load difficulty.

09:05.080 --> 09:09.970
And we're going to pass it difficulty index okay let me try this.

09:11.340 --> 09:12.720
I'm going to save it.

09:14.230 --> 09:16.330
And then we're going to go back to unity.

09:18.020 --> 09:19.460
Go to play mode.

09:21.020 --> 09:22.850
I'm going to do a new game.

09:25.150 --> 09:26.830
New game Hard mode.

09:27.490 --> 09:29.590
Let me choose the guy.

09:29.590 --> 09:33.280
Play level three and now we saved the difficulty.

09:33.370 --> 09:35.440
I can go and die, for example.

09:36.850 --> 09:38.890
Then I can exit play mode.

09:38.890 --> 09:40.240
Go to play mode.

09:46.430 --> 09:48.320
And we can click continue.

09:48.320 --> 09:50.210
And it's going to be hard over here.

09:50.240 --> 09:51.110
Okay.

09:51.230 --> 09:53.150
Very cool I like it.

09:55.820 --> 09:58.130
Uh, let's switch it to easy by default.

09:58.550 --> 09:59.000
All right.

09:59.000 --> 10:00.470
I'm going to save it now.

10:00.470 --> 10:02.000
Game is basically playable.

10:02.000 --> 10:03.290
You can make more levels.

10:03.290 --> 10:04.490
You can test levels.

10:04.490 --> 10:06.350
There are many different things you could do.

10:06.350 --> 10:08.240
But don't rush yet.

10:08.240 --> 10:10.850
We still have to do, um, sound effects.

10:10.850 --> 10:15.260
Also, I want to do a bit of polish and there are some other things, but probably you can just see

10:15.260 --> 10:17.990
them, you know, in the sections list on the course.

10:17.990 --> 10:19.640
Okay, I'll see you in the next video.
