1
00:00:00,000 --> 00:00:03,330
Welcome back, my fellow game developers.

2
00:00:03,330 --> 00:00:05,580
In this video, we are going to

3
00:00:05,580 --> 00:00:08,780
add a bit of functionality to our deaf screen.

4
00:00:08,775 --> 00:00:10,935
So currently when we walk around,

5
00:00:10,935 --> 00:00:12,765
we are alive and everything's good.

6
00:00:12,765 --> 00:00:14,255
When we die, we have

7
00:00:14,250 --> 00:00:16,280
the option to either restart the level,

8
00:00:16,275 --> 00:00:17,985
so we start off on the same level,

9
00:00:17,985 --> 00:00:19,955
or we have the option to go back to

10
00:00:19,950 --> 00:00:21,980
the main menu and cry a little bit.

11
00:00:21,975 --> 00:00:26,435
So let's not waste any more time and let's get started.

12
00:00:26,430 --> 00:00:30,300
Okay, so now we have everything.

13
00:00:30,300 --> 00:00:32,580
We have the title, we have the victory.

14
00:00:32,580 --> 00:00:35,760
It's time to do something about deaf screen.

15
00:00:35,760 --> 00:00:37,680
So currently when we die,

16
00:00:37,680 --> 00:00:41,710
you can see right now if we run the game with AI,

17
00:00:41,710 --> 00:00:44,780
you can see we have the UTI,

18
00:00:44,780 --> 00:00:45,800
we have the cooled lot,

19
00:00:45,800 --> 00:00:47,200
but there is nothing to do.

20
00:00:47,195 --> 00:00:48,805
So we've just sit there

21
00:00:48,800 --> 00:00:51,260
until we stop the play mode again.

22
00:00:51,260 --> 00:00:52,520
We don't want to do that.

23
00:00:52,520 --> 00:00:55,820
We want to have a continuous loop in our game.

24
00:00:55,820 --> 00:00:57,620
So I'm going to do is I'm going

25
00:00:57,620 --> 00:00:59,390
to go into the deaf screen.

26
00:00:59,390 --> 00:01:01,940
And here I'm going to right-click and I'm going

27
00:01:01,940 --> 00:01:04,700
to create a button or you know what?

28
00:01:04,700 --> 00:01:05,920
Before I do all of that,

29
00:01:05,915 --> 00:01:07,765
I'm going to issue you a challenge.

30
00:01:07,760 --> 00:01:09,500
And your challenge is going to be to

31
00:01:09,500 --> 00:01:12,260
create the two methods and the two buttons.

32
00:01:12,260 --> 00:01:14,690
So first of all, you need to create two buttons,

33
00:01:14,690 --> 00:01:16,220
want to restart the level and

34
00:01:16,220 --> 00:01:18,350
want to go back to the main menu.

35
00:01:18,350 --> 00:01:20,030
You will need to create a method

36
00:01:20,030 --> 00:01:21,710
for each of these buttons.

37
00:01:21,710 --> 00:01:23,780
And then you'll need to assign

38
00:01:23,780 --> 00:01:27,110
the functionalities to these two buttons.

39
00:01:27,110 --> 00:01:28,760
So with that out of the way,

40
00:01:28,760 --> 00:01:32,000
I believe you already know how to restart a level.

41
00:01:32,000 --> 00:01:34,790
You need to load the scene that we are

42
00:01:34,790 --> 00:01:38,440
currently on which we can get by getting seen active.

43
00:01:38,435 --> 00:01:43,315
So pause the video right now and go do the challenge.

44
00:01:43,310 --> 00:01:45,800
Oh, okay, welcome back.

45
00:01:45,800 --> 00:01:47,480
How did you get on with that?

46
00:01:47,480 --> 00:01:50,270
So because the current challenges

47
00:01:50,270 --> 00:01:51,380
are getting a bit

48
00:01:51,380 --> 00:01:53,810
boring because you already know everything.

49
00:01:53,810 --> 00:01:58,030
So I just loved the whole video to you.

50
00:01:58,025 --> 00:02:02,545
And I'm editing things without seeing even depth screen.

51
00:02:02,540 --> 00:02:04,070
So let's turn the Alpha to

52
00:02:04,070 --> 00:02:07,390
one so we can properly see the button.

53
00:02:07,385 --> 00:02:09,595
And let's see what we're going to do in here.

54
00:02:09,590 --> 00:02:11,570
So we have the button.

55
00:02:11,570 --> 00:02:16,000
Let's select this one and let's make it bigger.

56
00:02:15,995 --> 00:02:17,635
Move it to the left.

57
00:02:17,630 --> 00:02:19,790
And then in here we are going to

58
00:02:19,790 --> 00:02:22,340
remove the text and add our own texts.

59
00:02:22,340 --> 00:02:25,640
So everything I'm doing in here we have already covered.

60
00:02:25,640 --> 00:02:30,300
So say restart level.

61
00:02:30,304 --> 00:02:35,334
And let's set the proper everything,

62
00:02:35,330 --> 00:02:39,500
the proper everything and size, max,

63
00:02:39,500 --> 00:02:46,130
the max and the obviously the button right here

64
00:02:46,130 --> 00:02:50,020
should have the UI Elements Buttons

65
00:02:50,015 --> 00:02:52,915
and should have this sprite right here.

66
00:02:52,910 --> 00:02:54,950
There we go. So now we

67
00:02:54,950 --> 00:02:57,760
can increase the text and make it a bit bigger.

68
00:02:57,755 --> 00:03:00,125
There we go. We make it bold.

69
00:03:00,125 --> 00:03:02,035
Bold, I mean bold.

70
00:03:02,030 --> 00:03:06,740
So now we have the bold text and let's make this button.

71
00:03:06,740 --> 00:03:09,700
I've been bigger. Yeah, how does that look?

72
00:03:09,695 --> 00:03:11,705
I think it looks pretty good.

73
00:03:11,705 --> 00:03:13,565
So I'm going to duplicate this.

74
00:03:13,565 --> 00:03:14,995
Move this down here.

75
00:03:14,990 --> 00:03:19,660
This will be the main menu button,

76
00:03:19,655 --> 00:03:25,045
and the text will be the main menu.

77
00:03:25,040 --> 00:03:29,470
There we go. So I think that looks good enough.

78
00:03:29,465 --> 00:03:31,945
Let's maybe just know this, the text.

79
00:03:31,940 --> 00:03:40,900
I want to increase the text size a bit for the restart.

80
00:03:40,895 --> 00:03:43,825
And there we go. So I think that looks good enough.

81
00:03:43,820 --> 00:03:44,680
Save that.

82
00:03:44,675 --> 00:03:47,785
And now let's go ahead and add the functionalities.

83
00:03:47,780 --> 00:03:49,370
So in Scene Manager,

84
00:03:49,370 --> 00:03:51,200
we want to create everything.

85
00:03:51,200 --> 00:03:52,430
I mean, not unseen manager,

86
00:03:52,430 --> 00:03:53,620
you are a manager.

87
00:03:53,615 --> 00:03:56,575
We want to create the methods that take us from

88
00:03:56,570 --> 00:04:00,190
or restart the lover or take us to the main menu.

89
00:04:00,185 --> 00:04:02,225
But the thing here is,

90
00:04:02,225 --> 00:04:05,455
and this is a philosophy in game development.

91
00:04:05,450 --> 00:04:08,320
And where do you actually want to do this?

92
00:04:08,315 --> 00:04:11,735
So the UI Manager, what does it do?

93
00:04:11,735 --> 00:04:13,405
Does it take us from one scene

94
00:04:13,400 --> 00:04:15,100
to the next? No, it doesn't.

95
00:04:15,095 --> 00:04:18,785
It just manages the UI and this is its job.

96
00:04:18,785 --> 00:04:20,975
So a better place I believe,

97
00:04:20,975 --> 00:04:22,825
of doing this method or creating

98
00:04:22,820 --> 00:04:25,610
these methods as in the level manager,

99
00:04:25,610 --> 00:04:28,070
but also at the same time,

100
00:04:28,070 --> 00:04:29,780
we don't want the buttons to

101
00:04:29,780 --> 00:04:31,970
have access to the level manager.

102
00:04:31,970 --> 00:04:33,770
We just want the buttons to be able

103
00:04:33,770 --> 00:04:36,560
to change things in the UI Manager.

104
00:04:36,560 --> 00:04:38,150
So we are in a bit of

105
00:04:38,150 --> 00:04:40,480
a pickle if you want to call it that.

106
00:04:40,475 --> 00:04:43,135
So what I'm going to do is I'm going to trust

107
00:04:43,130 --> 00:04:44,960
my gut instincts and I'm

108
00:04:44,960 --> 00:04:47,090
going to create the methods in here.

109
00:04:47,090 --> 00:04:53,060
It's a public void restart level.

110
00:04:53,060 --> 00:04:56,650
And the way we restart the level is we simply

111
00:04:56,645 --> 00:05:00,175
get the scene manager, the load seen.

112
00:05:00,170 --> 00:05:03,700
And which scene are we going to load the scene manager,

113
00:05:03,695 --> 00:05:10,135
dot get active seen that build and x.

114
00:05:10,130 --> 00:05:12,400
So now we just load the scene

115
00:05:12,395 --> 00:05:14,275
of the current active scene.

116
00:05:14,270 --> 00:05:20,180
That means we reload the level and then public void re,

117
00:05:20,179 --> 00:05:24,849
return to main menu.

118
00:05:24,844 --> 00:05:27,354
And in here we are going to get

119
00:05:27,350 --> 00:05:30,730
this scene manager dot load scene.

120
00:05:30,725 --> 00:05:34,255
And we'll just load the scenes 0 because we know that

121
00:05:34,250 --> 00:05:36,860
the scene or the title scene

122
00:05:36,860 --> 00:05:40,450
or MainMenu scene is on the index 0.

123
00:05:40,445 --> 00:05:43,495
And now we'll go back into the UI Manager.

124
00:05:43,490 --> 00:05:47,180
And in here we are going to create the same methods.

125
00:05:47,180 --> 00:05:49,790
But instead of actually doing the things,

126
00:05:49,790 --> 00:05:50,810
we are going to access

127
00:05:50,810 --> 00:05:52,870
the level manager and do we have an instance?

128
00:05:52,865 --> 00:05:54,595
Yes, we do have an instance.

129
00:05:54,590 --> 00:05:56,570
So in here we are going to get

130
00:05:56,570 --> 00:06:03,870
the level manager dot instance, dot restart level.

131
00:06:04,000 --> 00:06:06,710
And let's do the same in here,

132
00:06:06,710 --> 00:06:08,980
but instead of restarting the level,

133
00:06:08,975 --> 00:06:11,225
return to main menu.

134
00:06:11,225 --> 00:06:14,015
So save that, go back into Unity.

135
00:06:14,015 --> 00:06:16,365
And I know this feels a bit redundant.

136
00:06:16,369 --> 00:06:17,839
I know this feels as if we're

137
00:06:17,840 --> 00:06:19,930
doing the same thing again and again.

138
00:06:19,925 --> 00:06:22,465
But I believe that this

139
00:06:22,460 --> 00:06:25,360
is a more proper way of doing things.

140
00:06:25,355 --> 00:06:27,695
So we can go to the UI Manager,

141
00:06:27,695 --> 00:06:31,675
restarted level and main menu.

142
00:06:31,670 --> 00:06:34,680
Go to your manager,

143
00:06:35,320 --> 00:06:37,540
and return to main menu.

144
00:06:37,535 --> 00:06:38,725
Save that.

145
00:06:38,720 --> 00:06:42,070
Let's turn off the depth screen.

146
00:06:42,065 --> 00:06:43,675
First of all, let's apply the changes

147
00:06:43,670 --> 00:06:45,610
that we've made apply.

148
00:06:45,605 --> 00:06:48,155
So now we turn off.

149
00:06:48,155 --> 00:06:51,445
First of all, we'll set the Alpha to 0.

150
00:06:51,440 --> 00:06:55,960
We will turn of the deaf screen.

151
00:06:55,955 --> 00:07:00,555
Larger the game die.

152
00:07:00,559 --> 00:07:03,619
And now we have the restart and main menu.

153
00:07:03,620 --> 00:07:04,790
If I click on the main menu,

154
00:07:04,790 --> 00:07:06,590
I go back to the main menu.

155
00:07:06,590 --> 00:07:07,430
Excellent.

156
00:07:07,430 --> 00:07:08,840
Let's try this again with the

157
00:07:08,840 --> 00:07:10,750
same of restarting the level.

158
00:07:10,745 --> 00:07:12,955
We die, we start level. There we go.

159
00:07:12,950 --> 00:07:15,430
We are back on level 2, baby.

160
00:07:15,425 --> 00:07:17,075
So excellent job.

161
00:07:17,075 --> 00:07:20,125
I hope you enjoy it. I hope you did this challenge.

162
00:07:20,120 --> 00:07:22,940
I hope you tried your best and I

163
00:07:22,940 --> 00:07:26,050
congratulate you if you did it from start to finish,

164
00:07:26,045 --> 00:07:27,275
all on your own.

165
00:07:27,275 --> 00:07:29,375
I'm going to stage everything,

166
00:07:29,374 --> 00:07:32,634
sage all commit the changes.

167
00:07:32,630 --> 00:07:38,360
Created a way to either restart the level

168
00:07:38,360 --> 00:07:44,870
or go back to Main Menu upon death.

169
00:07:44,870 --> 00:07:47,920
And not a way created.

170
00:07:47,915 --> 00:07:51,925
Two buttons to either

171
00:07:51,920 --> 00:07:53,570
restart the level all go back

172
00:07:53,570 --> 00:07:55,460
to the main menu upon death.

173
00:07:55,460 --> 00:07:56,690
And when the changes.

174
00:07:56,690 --> 00:07:58,610
If you haven't already leave me a review,

175
00:07:58,610 --> 00:08:00,140
if not, you can wait

176
00:08:00,140 --> 00:08:01,790
just a little bit and then leave me a review.

177
00:08:01,790 --> 00:08:03,530
This is the perfect time and I'll

178
00:08:03,530 --> 00:08:05,360
see you in the next one where we will be

179
00:08:05,360 --> 00:08:08,960
creating one of the cooler aspect of any game,

180
00:08:08,960 --> 00:08:10,550
which is the pause menu.

181
00:08:10,550 --> 00:08:12,930
So I'll see you then.

