1
00:00:00,000 --> 00:00:01,000
Hello, guys.

2
00:00:01,000 --> 00:00:03,000
In this video, we're going to set up pause button.

3
00:00:03,000 --> 00:00:04,000
Going to be pretty simple task.

4
00:00:04,000 --> 00:00:06,000
I want to go to the canvas.

5
00:00:07,000 --> 00:00:12,000
you-I mean, first we need to create a bullion private ball game post.

6
00:00:12,000 --> 00:00:15,000
Now let's create a function public void.

7
00:00:16,000 --> 00:00:17,000
Bull's game.

8
00:00:18,000 --> 00:00:21,000
And we're going to do simple check if game post.

9
00:00:23,000 --> 00:00:27,000
Then time the time scale equals to one.

10
00:00:27,000 --> 00:00:29,000
Regular time scale is one.

11
00:00:29,000 --> 00:00:31,000
Then we're going to say gain post is false.

12
00:00:31,000 --> 00:00:34,000
Then we're going to do ls and ls means.

13
00:00:34,000 --> 00:00:37,000
If game is not paused, then we're going to pause it.

14
00:00:37,000 --> 00:00:37,000
How are we going to do it?

15
00:00:37,000 --> 00:00:44,000
We're going to set time the time scale to zero, which allows us to stop all the time in the game and

16
00:00:44,000 --> 00:00:45,000
then game post equals true.

17
00:00:45,000 --> 00:00:48,000
So we have boolean prepared for the next check.

18
00:00:49,000 --> 00:00:50,000
In this if statement.

19
00:00:51,000 --> 00:00:51,000
All right.

20
00:00:51,000 --> 00:00:53,000
This is pretty simple and understandable.

21
00:00:53,000 --> 00:01:01,000
I'm going to find this post button hit plus drag canvas and then do UI pause game.

22
00:01:08,000 --> 00:01:08,000
Stopped.

23
00:01:08,000 --> 00:01:09,000
Resume.

24
00:01:09,000 --> 00:01:11,000
Stopped resume.

25
00:01:11,000 --> 00:01:11,000
Cool.

26
00:01:11,000 --> 00:01:13,000
Now you can notice something.

27
00:01:13,000 --> 00:01:17,000
After you clicked UI with your mouse, you can click the button again with your space key.

28
00:01:18,000 --> 00:01:24,000
So it's just activated by my space now, which is okay because it won't be there when you build the

29
00:01:24,000 --> 00:01:27,000
game, but it's kind of annoying when you're testing.

30
00:01:27,000 --> 00:01:33,000
So what we can do here is to go to this navigation and just choose none.

31
00:01:33,000 --> 00:01:36,000
And it's going to be fine and it won't be there.

32
00:01:41,000 --> 00:01:45,000
You can see I can jump now and there is no game post at the moment.

33
00:01:46,000 --> 00:01:46,000
Cool.

34
00:01:46,000 --> 00:01:48,000
Now next step would be to switch UI.

35
00:01:48,000 --> 00:01:51,000
It's going to be pretty simple with the setup we already have.

36
00:01:51,000 --> 00:01:51,000
Let's hit.

37
00:01:51,000 --> 00:01:53,000
Plus over here.

38
00:01:53,000 --> 00:01:54,000
Drag the canvas.

39
00:01:54,000 --> 00:01:59,000
Choose UI main switch menu to pause ui.

40
00:02:00,000 --> 00:02:08,000
And then in the post UI, we're going to open it, find a pause button and add almost the same functionality.

41
00:02:08,000 --> 00:02:09,000
Canvas.

42
00:02:09,000 --> 00:02:10,000
Canvas.

43
00:02:10,000 --> 00:02:16,000
First one will do post game to unpause it and second one will do UI.

44
00:02:16,000 --> 00:02:18,000
Main switch menu two.

45
00:02:18,000 --> 00:02:21,000
And we're going to switch to in-game UI.

46
00:02:21,000 --> 00:02:22,000
Pretty cool.

47
00:02:22,000 --> 00:02:25,000
Let's go and see this game post.

48
00:02:25,000 --> 00:02:27,000
I can click again and post.

49
00:02:30,000 --> 00:02:33,000
And regarding this button, well, let's do it right now.

50
00:02:33,000 --> 00:02:34,000
It's not that big of a deal.

51
00:02:34,000 --> 00:02:36,000
Let's find this main menu.

52
00:02:36,000 --> 00:02:37,000
Drag, canvas.

53
00:02:37,000 --> 00:02:38,000
Oh, wait a second.

54
00:02:38,000 --> 00:02:43,000
Plus, drag the canvas and choose UI main.

55
00:02:43,000 --> 00:02:45,000
We need a restart game.

56
00:02:45,000 --> 00:02:46,000
Do we have it?

57
00:02:46,000 --> 00:02:48,000
It's in the game Manager.

58
00:02:49,000 --> 00:02:50,000
Okay.

59
00:02:50,000 --> 00:02:54,000
So I want to move this function to UI as well.

60
00:02:57,000 --> 00:02:58,000
Let's find this UI main.

61
00:02:59,000 --> 00:03:01,000
Let's rename this buttons just a bit.

62
00:03:02,000 --> 00:03:07,000
Let's press control r r to rename it all and it's going to be start game button.

63
00:03:09,000 --> 00:03:10,000
This one as well.

64
00:03:10,000 --> 00:03:10,000
Pause.

65
00:03:10,000 --> 00:03:12,000
Game button.

66
00:03:13,000 --> 00:03:15,000
Then let's create one more here.

67
00:03:15,000 --> 00:03:16,000
Public void.

68
00:03:17,000 --> 00:03:22,000
Restart game button and it's going to do.

69
00:03:24,000 --> 00:03:26,000
Return game manager, for instance.

70
00:03:26,000 --> 00:03:28,000
Restart level.

71
00:03:29,000 --> 00:03:30,000
Now let's go and double check.

72
00:03:30,000 --> 00:03:32,000
We have all of those functions in the UI.

73
00:03:35,000 --> 00:03:42,000
Suppose the main menu function UI menu restart game button.

74
00:03:45,000 --> 00:03:46,000
Now this one is missing.

75
00:03:46,000 --> 00:03:48,000
Now we need to do UI.

76
00:03:49,000 --> 00:03:50,000
Post game button.

77
00:03:51,000 --> 00:03:56,000
Same here is going to miss here ui pause game button.

78
00:03:57,000 --> 00:03:58,000
And.

79
00:03:58,000 --> 00:04:00,000
Top to start as well.

80
00:04:01,000 --> 00:04:03,000
Top to start meetings.

81
00:04:03,000 --> 00:04:04,000
So we need to update.

82
00:04:08,000 --> 00:04:09,000
Where is it?

83
00:04:10,000 --> 00:04:11,000
Start game button.

84
00:04:11,000 --> 00:04:12,000
Okay.

85
00:04:19,000 --> 00:04:20,000
So we have.

86
00:04:22,000 --> 00:04:23,000
This.

87
00:04:25,000 --> 00:04:27,000
Bows and bows.

88
00:04:27,000 --> 00:04:28,000
Bows.

89
00:04:28,000 --> 00:04:29,000
Main menu.

90
00:04:31,000 --> 00:04:35,000
Now we can see we went to a new scene and game was restarted, but UI wasn't.

91
00:04:35,000 --> 00:04:39,000
So what we need to do here is something very simple.

92
00:04:39,000 --> 00:04:43,000
We just need to go to UI main and create start function.

93
00:04:44,000 --> 00:04:47,000
There's going to say switch menu, too.

94
00:04:47,000 --> 00:04:49,000
And now we need the reference to main menu.

95
00:04:49,000 --> 00:04:50,000
So let's do this.

96
00:04:51,000 --> 00:04:53,000
Serialize field Private game object.

97
00:04:54,000 --> 00:04:55,000
Main menu.

98
00:04:56,000 --> 00:04:57,000
Then.

99
00:04:57,000 --> 00:04:57,000
Here.

100
00:04:58,000 --> 00:04:59,000
Main menu.

101
00:05:01,000 --> 00:05:05,000
As we go to Unity and update the info main menu.

102
00:05:05,000 --> 00:05:12,000
And also at the start, we need to set timescale to one again because we set them scale to zero when

103
00:05:12,000 --> 00:05:16,000
we're in a post mode and when we go from the pause mode to main menu.

104
00:05:16,000 --> 00:05:21,000
We're not setting timescale back to one, so we need to do it in the start time.

105
00:05:21,000 --> 00:05:24,000
Dot timescale equals to one later.

106
00:05:24,000 --> 00:05:26,000
We can do it in the game manager, but for now we can do it here.

107
00:05:27,000 --> 00:05:29,000
Let's go to play mode and double check all of the buttons.

108
00:05:30,000 --> 00:05:32,000
By the way, I felt like these buttons are not working.

109
00:05:33,000 --> 00:05:34,000
Why is that?

110
00:05:34,000 --> 00:05:35,000
Didn't we set it up?

111
00:05:36,000 --> 00:05:38,000
Show button.

112
00:05:42,000 --> 00:05:42,000
We didn't.

113
00:05:50,000 --> 00:05:50,000
This is weird.

114
00:05:50,000 --> 00:05:53,000
Let's just update this real quick here.

115
00:05:53,000 --> 00:05:55,000
Plus and here plus.

116
00:05:56,000 --> 00:05:57,000
Go UI.

117
00:05:57,000 --> 00:06:01,000
Switch menu to switch to shop.

118
00:06:02,000 --> 00:06:03,000
Settings.

119
00:06:03,000 --> 00:06:05,000
Drag the canvas.

120
00:06:06,000 --> 00:06:07,000
I mean, switch to.

121
00:06:11,000 --> 00:06:13,000
Uh, settings UI.

122
00:06:14,000 --> 00:06:19,000
Now in the settings UI close button hit plus drag canvas.

123
00:06:20,000 --> 00:06:22,000
UI switch to main menu.

124
00:06:24,000 --> 00:06:26,000
Let's find clothes button in the shop.

125
00:06:29,000 --> 00:06:30,000
Plus.

126
00:06:30,000 --> 00:06:31,000
Canvas.

127
00:06:33,000 --> 00:06:36,000
UI switch menu to main menu.

128
00:06:43,000 --> 00:06:46,000
Now we have to start shop.

129
00:06:47,000 --> 00:06:49,000
We can go back settings.

130
00:06:49,000 --> 00:06:52,000
We can go back top to start.

131
00:06:52,000 --> 00:06:53,000
I can play.

132
00:06:53,000 --> 00:06:54,000
I can click.

133
00:06:54,000 --> 00:06:56,000
Pause and pause.

134
00:06:56,000 --> 00:06:56,000
I can click.

135
00:06:56,000 --> 00:06:57,000
Pause.

136
00:06:57,000 --> 00:07:00,000
Go to Main menu and I'm in the main menu again.

137
00:07:01,000 --> 00:07:02,000
Cool.

138
00:07:02,000 --> 00:07:03,000
All right.

139
00:07:03,000 --> 00:07:05,000
That's it for this video.

140
00:07:05,000 --> 00:07:06,000
Let's go to next one.

