WEBVTT

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

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

00:01.490 --> 00:07.340
In this one I want to show you how to make the pose UI so you can pause the game while you're playing.

00:07.340 --> 00:09.830
And also you can click escape and go to main menu.

00:09.860 --> 00:11.180
Simple task here.

00:11.180 --> 00:13.130
And we just need to make.

00:14.920 --> 00:16.390
Let's make UI.

00:17.760 --> 00:20.700
Uh, I guess we can do image now.

00:20.700 --> 00:21.480
Let's not do image.

00:21.480 --> 00:24.390
Let's do empty object pose.

00:24.870 --> 00:25.710
Pose UI.

00:25.740 --> 00:26.340
Okay.

00:27.980 --> 00:32.420
On this post, we need to stretch it on the entire screen.

00:32.570 --> 00:37.190
Now let's focus on this and we can make some sort of a button.

00:38.930 --> 00:40.370
Button text Mesh Pro.

00:42.240 --> 00:43.470
Uh, it would do.

00:43.470 --> 00:44.580
Resume.

00:44.760 --> 00:46.710
Uh, actually, let's set up the button first.

00:46.710 --> 00:50.400
Let's do 250 by 100.

00:51.260 --> 00:54.140
And this would say resume.

00:56.140 --> 00:58.030
Let's make text white.

00:58.900 --> 01:01.120
Let's do Minecraft font.

01:01.540 --> 01:03.580
Okay, I think I like it.

01:03.580 --> 01:05.140
Maybe bigger font.

01:07.410 --> 01:09.000
Or G6.

01:11.960 --> 01:13.100
Maybe a bigger button.

01:13.790 --> 01:15.890
350 by 150.

01:16.740 --> 01:17.460
Yeah, it looks good.

01:17.490 --> 01:18.690
So you cannot miss it.

01:21.580 --> 01:25.540
And let's change it to resume.

01:26.560 --> 01:29.950
Button and we want to duplicate this.

01:31.130 --> 01:34.790
Bring it down and change this to.

01:36.040 --> 01:40.420
Menu button and this will have something like.

01:41.190 --> 01:42.240
Main menu.

01:42.820 --> 01:49.000
Yeah, we need to decrease font a little bit, but we can just do 68 over here or 58.

01:50.830 --> 01:51.760
58.

01:53.020 --> 01:54.280
64.

01:54.700 --> 01:55.390
64.

01:55.390 --> 01:56.230
Looks good.

01:56.530 --> 01:58.870
Okay, let's take resume and do 64 as well.

01:58.870 --> 02:00.670
So it's the same.

02:01.860 --> 02:03.150
Let me think.

02:03.480 --> 02:06.450
I don't like how the like.

02:06.450 --> 02:07.890
I don't like the height of the buttons.

02:07.890 --> 02:10.170
So I'm going to try to do 100 here.

02:11.950 --> 02:13.150
Yeah, it looks better.

02:13.180 --> 02:14.740
Let me take the text.

02:15.660 --> 02:19.320
Change the textbox size over here and over here.

02:19.320 --> 02:23.100
Now we want to make UI image.

02:23.700 --> 02:29.610
We want to stretch it on the entire UI and we want to make it.

02:30.920 --> 02:35.960
Dark and transparent, and I guess we need to place it above the buttons.

02:37.310 --> 02:38.930
So buttons dominate.

02:39.170 --> 02:39.920
Nice.

02:41.360 --> 02:43.040
Um, pose.

02:43.980 --> 02:45.630
Dark screen.

02:47.730 --> 02:49.350
Let's make it Unclickable.

02:49.350 --> 02:51.150
We're going to click over here.

02:51.390 --> 02:51.810
Raycast.

02:51.810 --> 02:52.530
Target.

02:53.330 --> 02:56.180
And that's probably it for the UI itself.

02:56.180 --> 03:00.140
The only thing I want to change is to make buttons a little bit transparent here.

03:06.120 --> 03:07.110
Like that.

03:07.230 --> 03:08.010
Okay.

03:08.010 --> 03:09.240
This is very good.

03:09.270 --> 03:10.140
I like it.

03:10.320 --> 03:12.480
Now we need to make functionality for this.

03:12.480 --> 03:14.700
We can go to UI in game.

03:16.940 --> 03:18.920
And I'm going to make a method.

03:19.920 --> 03:20.910
Public void.

03:22.440 --> 03:24.510
Pause button.

03:26.620 --> 03:34.600
Now we need a boolean that defines if game is paused at the moment Privatebool is paused.

03:35.230 --> 03:37.120
And then over here in a pause button.

03:37.120 --> 03:39.940
We're going to do this if is paused.

03:41.780 --> 03:45.350
Then it means we resuming the game when we pressing this button.

03:45.350 --> 03:49.250
So we're going to do is post equals to false.

03:50.940 --> 03:54.600
And we're going to do time dot time scale equals to one.

03:54.600 --> 03:59.040
So time scale defines how like how fast game goes.

03:59.040 --> 04:00.210
You know it's a time scale.

04:00.210 --> 04:03.810
If you make it uh point five you're going to have a slow motion in the game.

04:03.810 --> 04:06.600
But it does not work very well in the pixelated game.

04:06.600 --> 04:11.730
Anyway, with this one, we're going to return normal time to the game, and we're going to say that

04:11.730 --> 04:13.290
game is not paused anymore.

04:13.410 --> 04:15.630
And over here we're going to do else.

04:15.630 --> 04:18.690
So if it's not post then we're going to do is post.

04:19.870 --> 04:23.470
It was to true and time to time scale equals to zero.

04:23.500 --> 04:26.260
Now even this alone is going to work.

04:26.290 --> 04:31.240
I just want to open up date and I'm going to do if input.

04:31.890 --> 04:33.060
Get key down.

04:34.660 --> 04:37.600
He called and I'm going to choose letter B for this.

04:37.600 --> 04:39.370
But you can use any other letter.

04:39.370 --> 04:42.490
And if I'm pressing P I'm going to call pause button.

04:42.790 --> 04:44.140
But now this should be enough.

04:44.170 --> 04:46.030
Let's go back to the game.

04:48.620 --> 04:51.410
Let's disable this false UI for now.

04:52.430 --> 04:55.070
And let's just try the pause system.

04:57.110 --> 04:58.250
So I'm in the game.

04:58.250 --> 05:01.160
I'm going to press P and game stopped.

05:01.650 --> 05:02.610
Timer stopped.

05:02.640 --> 05:03.810
Everything stopped.

05:03.810 --> 05:04.500
Very cool.

05:04.500 --> 05:05.940
If I'm pressing P again.

05:05.970 --> 05:07.800
Game is resumed.

05:07.800 --> 05:09.120
So it works.

05:09.120 --> 05:10.920
Now we need to, um.

05:12.440 --> 05:14.750
Enable this UI when we press in the button.

05:14.750 --> 05:17.270
And also we need to set up these two buttons.

05:17.270 --> 05:17.990
Right.

05:17.990 --> 05:19.220
Let's go back.

05:20.500 --> 05:22.150
Let's get reference.

05:23.020 --> 05:26.560
Private game object pose UI.

05:28.590 --> 05:33.210
And we need a method that would go to the main menu.

05:33.660 --> 05:35.070
So.

05:37.840 --> 05:38.350
Over here.

05:38.350 --> 05:40.060
I'm going to do public void.

05:45.230 --> 05:49.490
Go to main menu button.

05:51.160 --> 05:53.800
And we know that main menu has index zero.

05:53.800 --> 05:55.840
So I'm just going to do seed manager.

05:56.670 --> 05:59.070
Below the scene of zero.

05:59.190 --> 06:00.480
This should be enough.

06:00.510 --> 06:02.190
Okay, let's save this.

06:02.250 --> 06:03.960
Let's go back to unity.

06:06.740 --> 06:08.420
On the resume button.

06:08.420 --> 06:19.550
We need to add event drag UI in game, find UI in game, and just assign a pause button over here for

06:19.550 --> 06:20.510
the main menu.

06:20.540 --> 06:25.370
We need to add event drag UI in game and assign.

06:26.560 --> 06:28.150
And go to main menu button.

06:29.290 --> 06:31.450
All right, now let's go to play mode.

06:35.460 --> 06:36.900
I'm going to click escape.

06:38.010 --> 06:39.540
Oh, I forgot something.

06:39.540 --> 06:40.290
I'm so sorry.

06:40.440 --> 06:41.190
Yeah.

06:41.250 --> 06:45.600
Uh, let's go to UI in game, and let's drag this pose UI over here.

06:45.600 --> 06:47.820
So we have reference to the game object.

06:48.770 --> 06:50.960
And then over here we're going to do.

06:52.260 --> 06:53.010
Pause UI.

06:53.040 --> 06:55.800
Set active false.

06:55.800 --> 06:57.810
And over here we're going to do pause UI.

06:57.840 --> 06:59.100
Set active true.

06:59.610 --> 07:00.750
This is what I forgot.

07:01.340 --> 07:02.630
Let's save this.

07:04.700 --> 07:05.870
Let's go back.

07:12.020 --> 07:13.850
And now supposed to work.

07:14.420 --> 07:15.770
Going to press escape.

07:16.520 --> 07:17.060
Oh, why?

07:17.060 --> 07:17.810
I'm pressing escape.

07:17.810 --> 07:18.920
It's a platter.

07:19.460 --> 07:19.850
Yes.

07:19.850 --> 07:20.690
So?

07:23.370 --> 07:24.510
It's working.

07:29.080 --> 07:29.770
Very good.

07:29.770 --> 07:31.300
And you can click resume.

07:32.200 --> 07:33.130
Works as well.

07:34.290 --> 07:36.000
And you can go to main menu.

07:36.480 --> 07:37.140
All right.

07:37.140 --> 07:38.550
So this works.

07:38.550 --> 07:41.040
Let's uh go to UI in game.

07:41.040 --> 07:43.620
Let's do apply all.

07:43.980 --> 07:51.840
Now we can go to another scene and test this scene level two I'm going to save it here we have post

07:51.870 --> 07:52.110
UI.

07:52.140 --> 07:53.700
Now it is disabled.

07:57.390 --> 08:00.750
And in the next scene I can press the pause game as well.

08:01.080 --> 08:02.010
Alrighty.

08:02.100 --> 08:03.570
See you in the next video.
