WEBVTT

00:00.050 --> 00:00.560
Hello guys.

00:00.560 --> 00:01.460
Welcome to the video.

00:01.460 --> 00:03.500
In this one we're going to work on the main menu.

00:03.500 --> 00:06.500
We need to adapt it so it works for two players.

00:06.500 --> 00:09.200
Let's go to main menu I'm going to save changes.

00:09.200 --> 00:13.490
And over here we need to adjust the system a little bit.

00:13.490 --> 00:18.740
First of all I think we should disable continue button because before we use continue button to go to

00:18.740 --> 00:24.050
the last level player played, and there was a way to save information about skin he used.

00:24.050 --> 00:29.210
But now since we can have two players, we never know which player used which skin.

00:29.210 --> 00:34.430
Although we could save skin under like some sort of player one and player two variable, there is no

00:34.430 --> 00:39.590
way of knowing who is going to be player one and player two in the next game, so it is better and easier

00:39.590 --> 00:42.770
to allow player to choose skins every time they play.

00:42.770 --> 00:46.910
And if that's the case, I think we just should make a play button.

00:46.910 --> 00:51.080
And then every time somebody plays, he will do the entire setup from the start.

00:51.080 --> 00:52.460
I think it will be easier.

00:52.460 --> 00:54.830
Okay, let's go to main menu.

00:54.830 --> 00:57.530
Let's disable continue button.

00:57.530 --> 01:02.420
And on the main menu we did enable continue button with some.

01:03.260 --> 01:04.280
A condition.

01:04.280 --> 01:07.550
I don't remember the condition, but let me check.

01:11.620 --> 01:12.400
Or is it?

01:15.600 --> 01:16.950
Continue button.

01:18.310 --> 01:21.730
If has level progression then enable continue button.

01:21.730 --> 01:23.440
So I'm just going to.

01:24.260 --> 01:28.400
Comment this out and let me take this hedge level progression method.

01:29.160 --> 01:31.110
And I think it can be just there.

01:31.110 --> 01:34.770
Let's leave it and I'm going to comment this out in case you want to use it.

01:34.770 --> 01:35.190
Okay.

01:35.190 --> 01:36.450
But I will not.

01:38.420 --> 01:41.480
Now next step we need to go back to menu.

01:41.870 --> 01:45.710
And we need to change text on this button from New Game to Play.

01:47.420 --> 01:53.540
So let's just type play like that and we could take these two buttons.

01:53.570 --> 01:54.740
Let me find it.

01:54.770 --> 01:58.730
We can just drag them a bit higher like that.

01:58.970 --> 02:03.740
And let me take the new game button I'm going to duplicate it.

02:03.740 --> 02:08.750
Move it below and I'll just name it as quit button.

02:09.840 --> 02:10.440
Yes.

02:10.440 --> 02:12.060
And we're going to make functionality for it.

02:12.060 --> 02:15.450
So you can, uh, quit the game from a menu.

02:19.090 --> 02:20.890
Now let's take the play button.

02:20.890 --> 02:24.550
Let's find navigation I'm going to change it to explicit.

02:25.150 --> 02:33.220
And from new button we're going to go to Settings Up and no sorry settings down.

02:34.090 --> 02:34.600
And quit.

02:34.600 --> 02:35.860
Game up.

02:36.520 --> 02:38.710
Let's change the order over here.

02:38.710 --> 02:39.400
Yeah.

02:39.550 --> 02:43.780
This one should say quit or exit.

02:46.190 --> 02:47.270
We'd better.

02:48.440 --> 02:50.000
And on a quit button.

02:50.630 --> 02:52.970
We need to change navigation to explicit.

02:54.850 --> 02:59.320
And let's do up settings down new game.

02:59.320 --> 03:01.030
Let me double check the settings.

03:03.230 --> 03:07.520
Up going to be new game and down going to be.

03:08.470 --> 03:10.360
I quit just like that.

03:10.390 --> 03:13.120
Okay, let me check this real quick.

03:18.500 --> 03:19.010
Yeah.

03:19.010 --> 03:20.690
Works good, I love it.

03:23.220 --> 03:26.670
Let's change the name over here to a play game button.

03:27.120 --> 03:32.850
And then let's go ahead to main menu and duplicate it.

03:32.850 --> 03:35.130
I'm going to press Ctrl D to duplicate.

03:35.130 --> 03:40.530
Then I want to disable main menu and this one should be layer mode UI.

03:41.200 --> 03:42.220
Very nice.

03:42.250 --> 03:45.790
Now, let's, uh, delete the quit button.

03:45.790 --> 03:47.920
We need a back button in this UI.

03:47.920 --> 03:51.730
So I'm going to copy this, paste it in and move it over here.

03:51.730 --> 03:53.260
Now we have a back button.

03:55.180 --> 03:57.490
And these two should be changed.

03:57.490 --> 03:59.260
I can remove continue button.

03:59.890 --> 04:01.780
And these two should be changed.

04:01.810 --> 04:06.040
So this one's going to be one player mode button.

04:07.510 --> 04:09.040
And this one should be.

04:10.840 --> 04:12.190
Two player mode button.

04:17.270 --> 04:18.530
Let's change the text.

04:18.530 --> 04:19.640
One player.

04:22.150 --> 04:23.560
And over here.

04:23.560 --> 04:25.300
Two layers.

04:25.300 --> 04:26.380
Very nice.

04:26.380 --> 04:28.570
Let's check the navigation.

04:28.870 --> 04:33.850
So this one goes up to back button down to two layers button.

04:34.360 --> 04:39.430
This one is up to one layer button down to back button and back button.

04:40.100 --> 04:44.720
Down to one player button and up to two player button.

04:45.390 --> 04:46.020
Okay.

04:46.020 --> 04:47.220
Two players.

04:50.620 --> 04:51.370
Very good.

04:51.400 --> 04:57.790
Now, this buttons supposed to set, uh, amount of players on a player manager, which we don't have

04:57.790 --> 04:58.930
in this scene yet.

05:02.190 --> 05:04.620
So let's go to asset prefabs.

05:04.620 --> 05:05.730
Managers.

05:05.730 --> 05:07.080
Player manager.

05:09.190 --> 05:12.880
And we're going to go ahead here and.

05:13.800 --> 05:14.610
Let's.

05:16.910 --> 05:18.200
Make a method.

05:19.110 --> 05:20.070
Public void.

05:21.160 --> 05:27.040
Set up max players count and we're going to pass in max player count here.

05:27.460 --> 05:29.290
And let's do a new player count.

05:29.890 --> 05:31.630
New player count.

05:32.220 --> 05:35.430
And then max player count is equals to new player count.

05:35.430 --> 05:41.610
And also we need to take player input manager and ask it to set up maximum player count to new max player

05:41.610 --> 05:42.360
count.

05:42.360 --> 05:43.440
Just like that.

05:43.800 --> 05:48.450
And then we can go to the wake and remove this line of code from here.

05:48.450 --> 05:49.740
We don't need it anymore.

05:49.740 --> 05:50.970
I'm going to remove it.

05:50.970 --> 05:53.010
I'm going to save the script.

05:53.580 --> 05:55.440
And then let's go back to unity.

06:00.420 --> 06:01.650
In unity itself.

06:01.650 --> 06:07.080
We need to take these two buttons and we need to add a method on click.

06:07.110 --> 06:09.900
We're going to drag a player manager over here.

06:09.900 --> 06:15.060
And we're going to choose player manager set up max player count.

06:15.390 --> 06:18.120
Okay now for this one it should be one.

06:18.390 --> 06:20.100
For this one it should be two.

06:20.970 --> 06:21.690
Very good.

06:21.690 --> 06:25.350
Also, let's make sure we switch into, uh, correct UI.

06:25.350 --> 06:29.130
So these two are supposed to lead us to difficulty UI.

06:29.160 --> 06:34.440
So I'm going to drag difficulty UI over here, then play game button.

06:34.440 --> 06:36.690
Supposed to lead us to play mode UI.

06:36.690 --> 06:40.320
So I'm going to drag player mode over here.

06:40.980 --> 06:44.700
Other than that, I think it should be good on the player manager itself.

06:44.700 --> 06:50.340
We need to disable joining enabled because otherwise you can create a player in the menu and we don't

06:50.340 --> 06:50.940
want to do that.

06:50.940 --> 06:53.340
So I'm going to disable this mark over here.

06:53.340 --> 06:54.720
And.

06:55.560 --> 06:57.990
This probably is good.

06:58.410 --> 06:59.130
Uh oh.

06:59.130 --> 07:06.030
Also on UI elements over here, we need to be sure we did drag player mode UI over here.

07:07.100 --> 07:09.200
Okay, let's go ahead and try this.

07:11.390 --> 07:12.890
I'm going to use my gamepad.

07:15.850 --> 07:19.960
Play player one normal, you're going to select the player.

07:19.960 --> 07:24.730
Level one there is me I can join and second player cannot join.

07:25.060 --> 07:26.020
Very nice.

07:26.020 --> 07:27.370
This is super good.

07:27.790 --> 07:32.110
Now let's go back and let's try with two players.

07:33.010 --> 07:40.000
I'm going to go back, then I'm going to go to play two players normal select level one.

07:40.000 --> 07:43.090
I can draw in and second guy can join as well.

07:43.790 --> 07:44.660
Very nice.

07:44.660 --> 07:45.830
So it's working.

07:46.130 --> 07:47.780
Uh, a couple of more things.

07:47.780 --> 07:49.760
First of all, we want to make this.

07:50.660 --> 07:51.740
Quit button.

07:52.520 --> 07:53.540
Work.

07:53.780 --> 07:57.020
Let's go to, uh, canvas.

07:58.150 --> 07:59.530
Let's make a method.

08:03.120 --> 08:04.020
I'm going to do.

08:04.760 --> 08:05.510
Public.

08:05.870 --> 08:06.860
Public void.

08:06.860 --> 08:07.610
Quit.

08:08.000 --> 08:08.930
Button.

08:09.350 --> 08:10.310
And then over here.

08:10.310 --> 08:11.510
We need to check something.

08:11.510 --> 08:17.840
We're going to type if editor application is plain, which means we are in the play mode.

08:18.050 --> 08:20.840
Then we're going to do editor application.

08:22.710 --> 08:24.900
He's plane equals to false.

08:25.050 --> 08:27.510
Else we're going to do application.

08:29.090 --> 08:36.170
Dot quit and this will close the game if you are in the game in build, not in the unity editor.

08:36.200 --> 08:38.360
Okay, now let's go back.

08:40.270 --> 08:41.890
Let's take this quit button.

08:45.830 --> 08:51.710
And we're going to change it from difficult to UI to main menu quit button.

08:52.040 --> 08:53.300
Now let me try this.

08:58.320 --> 08:59.670
And we stop the play mode.

08:59.700 --> 09:06.450
Okay, last system I want to make in this video is a message that would say, press a button to join

09:06.450 --> 09:08.070
the game right in the start.

09:08.070 --> 09:13.140
Before you press the button for that, we need to go to player manager, and we need to make a list

09:13.140 --> 09:17.160
of objects that we will disable once first player is joining.

09:17.160 --> 09:18.900
So I'm going to do.

09:20.750 --> 09:22.220
Sterilized field.

09:22.580 --> 09:23.960
Private game object.

09:23.960 --> 09:24.560
Array.

09:24.590 --> 09:27.020
Objects to disable.

09:27.440 --> 09:30.380
And then we want to go somewhere below.

09:32.420 --> 09:33.290
Over here.

09:33.290 --> 09:35.900
And I'm going to do for each.

09:36.590 --> 09:37.430
VAR.

09:38.520 --> 09:39.450
Game object.

09:40.460 --> 09:44.600
In objects to disable, we're going to do GameObject.

09:45.270 --> 09:47.340
Set active pulse.

09:47.340 --> 09:48.720
We're going to need it later.

09:48.750 --> 09:50.910
Also, we can change this wire to GameObject.

09:50.910 --> 09:51.930
Doesn't really matter.

09:52.930 --> 09:55.090
Let's save this and let's go to unity.

09:58.720 --> 10:00.820
Now over here inside of UI.

10:00.820 --> 10:06.370
In game we want to make UI text Mesh Pro.

10:07.370 --> 10:10.700
This one going to be saying press to join.

10:11.830 --> 10:12.490
Text.

10:12.870 --> 10:17.130
And this one will say something like press any key to join.

10:18.210 --> 10:21.210
Now let's change the font to Minecraft.

10:21.240 --> 10:22.770
Let's make it bigger.

10:22.770 --> 10:29.070
I need to find this text, and I think we need to increase the text size to something like this.

10:29.160 --> 10:31.920
We need to attach it to the center of the screen.

10:31.920 --> 10:36.210
Let's do alignment in the center and let's make this font really big.

10:37.080 --> 10:39.810
Uh, something like this should work, I like it.

10:41.690 --> 10:44.270
Now let's go to scripts of UI.

10:46.330 --> 10:47.140
And over here.

10:47.140 --> 10:48.490
I want to make a new one.

10:48.490 --> 10:53.050
It's going to be UI text blink effect.

10:53.380 --> 10:56.590
I'm sure there is a better word for it, but I'm going to use this one.

10:56.710 --> 11:00.340
Let me open that script UI blink effect.

11:00.340 --> 11:05.440
And first we want to know the duration of the cycle like during how long.

11:05.440 --> 11:11.260
It will be transparent not transparent transparent like that.

11:11.260 --> 11:16.570
So we're going to do serialized field private float cycle duration.

11:16.570 --> 11:19.120
And then we want to get component of a text itself.

11:19.120 --> 11:23.020
So I'm going to do private text mesh pro GUI text.

11:23.020 --> 11:24.700
And let's open a wake.

11:25.580 --> 11:28.400
Handle text equals to get component of a text mesh Pro.

11:28.430 --> 11:29.180
Very nice.

11:29.180 --> 11:33.680
Now let's make a method that will make it transparent or fully white.

11:33.710 --> 11:39.050
I'm going to do private void toggle color and which we need to pass color.

11:39.140 --> 11:43.280
And then we're going to do text dot color equals to color.

11:43.280 --> 11:44.150
Very good.

11:44.150 --> 11:48.380
And now we want to start a coroutine that will make this text blink.

11:48.380 --> 11:54.200
And I'm going to show you a way to make an infinite loop the endless loop okay.

11:54.200 --> 11:56.690
Let's do private ienumerator.

11:58.050 --> 11:58.740
I'm going to do.

11:58.740 --> 11:59.520
Blink.

11:59.520 --> 12:00.990
Coroutine.

12:04.680 --> 12:08.190
And then inside of this coroutine, first of all we want to get half cycle.

12:08.190 --> 12:15.000
So I'm going to do float half cycle equals to cycle duration divided by two.

12:15.270 --> 12:21.000
And then to make an infinite loop that will play all the time until you disable the game object, you

12:21.000 --> 12:25.950
can do while true and then do functionality inside.

12:25.950 --> 12:29.010
And this will basically work as an infinite loop.

12:29.010 --> 12:31.230
So here we're going to do toggle color.

12:32.650 --> 12:34.270
And we need transparent color.

12:34.270 --> 12:35.860
I think we can just.

12:37.030 --> 12:39.190
Do we need to set up transparent color though?

12:41.020 --> 12:42.160
I remember the alpha.

12:42.160 --> 12:44.110
So I'm going to do private color.

12:44.470 --> 12:50.230
Transparent color equals to new color of 111..

12:50.230 --> 12:51.790
Let's do point for alpha.

12:54.260 --> 12:55.400
I maybe even point two.

12:55.430 --> 12:56.750
Let's try that then.

12:56.750 --> 12:58.730
Over here we're going to pass transparent color.

12:58.730 --> 13:04.940
Then we're going to do yield return new wait four seconds of half cycle.

13:04.940 --> 13:06.170
Then we're going to make.

13:07.260 --> 13:08.250
Toggle color.

13:09.300 --> 13:10.560
Coloured or white.

13:15.530 --> 13:18.560
And then we're going to wait again for the half of the cycle.

13:18.560 --> 13:23.000
And this will run an infinite loop that will make image blink all the time.

13:23.060 --> 13:26.600
Let's go and start a coroutine in the wake.

13:26.600 --> 13:29.990
Start coroutine of a blink coroutine.

13:29.990 --> 13:31.010
Just like that.

13:31.980 --> 13:35.280
And then we want to stop the coroutine when we disable the game object.

13:35.280 --> 13:40.290
So I'll do on disable stop all coroutines.

13:40.350 --> 13:41.490
Very nice.

13:44.010 --> 13:45.270
Now let's go back.

13:49.150 --> 13:57.460
And on a player manager, we have this array of game objects that we should disable once we start the

13:57.460 --> 13:58.060
game.

13:58.060 --> 14:03.040
What I'm worried about is that we may pass player manager from the main menu, and it will not have

14:03.040 --> 14:09.100
this object to disable inside of this, uh, array over here.

14:09.100 --> 14:16.060
So somehow we need to add this text to the array over here.

14:17.970 --> 14:19.410
How could we do that?

14:19.680 --> 14:22.080
I think we should turn it into a list.

14:22.660 --> 14:25.840
Not array but list so we can dynamically change it.

14:27.690 --> 14:29.730
And the list of game objects.

14:30.540 --> 14:31.650
Like that.

14:31.890 --> 14:34.920
And then we need to go to UI in game.

14:36.100 --> 14:38.020
And in the start.

14:38.650 --> 14:39.580
Start.

14:41.620 --> 14:42.700
Where is the start method?

14:43.300 --> 14:44.140
Why cannot.

14:44.140 --> 14:46.660
Ah, there is a start method.

14:46.660 --> 14:50.440
And over here I want to do something like GameObject.

14:50.980 --> 14:56.980
Press join text equals to find first object by type of text.

14:56.980 --> 15:00.310
Blink effect dot GameObject.

15:01.090 --> 15:08.530
Then we're going to take player manager dot instance and objects to disable or not at least is private.

15:09.010 --> 15:10.180
Uh, let's go back.

15:12.000 --> 15:13.440
Let's just make it public.

15:14.300 --> 15:16.520
Then we're going to go back to UI in game.

15:17.580 --> 15:21.600
And we're going to do objects to disable ad press join text.

15:22.110 --> 15:22.440
Okay.

15:22.440 --> 15:28.440
So now every time we start a new scene, it will add this object of a blinking text to that list.

15:28.440 --> 15:32.460
And then we will disable that game object once player presses the button.

15:32.850 --> 15:34.230
Let's go and try this.

15:37.280 --> 15:38.930
Should be fine.

15:40.020 --> 15:40.380
Okay.

15:40.380 --> 15:41.610
We just need to.

15:42.530 --> 15:44.960
Take the component from UI folder.

15:45.620 --> 15:48.170
And we need to drag it over here.

15:48.820 --> 15:54.970
Like that cycle duration to text will be assigned automatically, so it should be good.

15:55.120 --> 15:56.440
Let's go and try this.

15:58.640 --> 16:02.900
And we have text being transparent and not transparent.

16:02.900 --> 16:04.670
And I kind of like how it works.

16:04.670 --> 16:10.520
If you want smooth change of the color from transparent to fully white, and then the opposite, then

16:10.520 --> 16:14.450
you would have to do something like we did with the fade image.

16:14.450 --> 16:17.540
But I think I'm going to keep this one because I like it.

16:17.540 --> 16:18.200
All right.

16:19.130 --> 16:21.500
And I press the button and text disappears.

16:21.530 --> 16:22.370
Very good.

16:22.790 --> 16:23.540
Very good.

16:23.570 --> 16:25.430
Now let me apply overrides.

16:27.100 --> 16:30.280
And I'm going to go to main menu and I'm going to see.

16:31.080 --> 16:33.330
The entire sequence all together.

16:33.330 --> 16:34.290
Let's go.

16:36.910 --> 16:37.630
Play.

16:37.630 --> 16:38.110
Play.

16:38.110 --> 16:38.710
Normal.

16:38.710 --> 16:39.220
Select.

16:39.220 --> 16:40.030
Select.

16:40.540 --> 16:42.430
Press any key to join.

16:42.430 --> 16:43.570
Okay.

16:44.290 --> 16:45.490
Good, I love it.

16:46.220 --> 16:48.290
And maybe we can adjust it a little bit.

16:49.920 --> 16:52.560
UI text blink effect.

16:52.560 --> 16:53.790
You know what we could do?

16:53.820 --> 16:58.170
First of all, we could make it white, then transparent.

16:58.690 --> 16:59.530
Like that.

16:59.530 --> 16:59.950
All right.

16:59.950 --> 17:01.870
So it will not become transparent immediately.

17:01.870 --> 17:03.910
First it will be white.

17:04.300 --> 17:05.410
Uh, let me double check that.

17:05.410 --> 17:07.120
And I think we're good with this video.

17:07.120 --> 17:08.440
We can go to next one.

17:13.490 --> 17:15.470
Yeah, like on the old machines.

17:15.470 --> 17:16.490
Very nice.

17:16.490 --> 17:18.770
Okay, I'll see you in the next video.
