1
00:00:00,000 --> 00:00:03,630
Welcome back My favorite game developers

2
00:00:03,630 --> 00:00:05,450
to a brand new long video.

3
00:00:05,445 --> 00:00:07,955
And in this one, when we run the game,

4
00:00:07,950 --> 00:00:13,320
you'll see that we have the pine bought invader 2D.

5
00:00:13,320 --> 00:00:15,030
Why does it sound like that?

6
00:00:15,030 --> 00:00:16,560
But anyways, we have two buttons.

7
00:00:16,560 --> 00:00:19,350
The exit button that just displays this text right here,

8
00:00:19,350 --> 00:00:22,170
and the Start button when we choose it, there we go.

9
00:00:22,170 --> 00:00:24,300
We go to the first level.

10
00:00:24,300 --> 00:00:25,650
How cool is that?

11
00:00:25,650 --> 00:00:27,540
We can shoot, we can get help,

12
00:00:27,540 --> 00:00:28,740
we can also die.

13
00:00:28,740 --> 00:00:33,450
So let's not waste any more time and let's get started.

14
00:00:33,445 --> 00:00:35,395
Oh, case.

15
00:00:35,390 --> 00:00:38,380
So time to create a couple of

16
00:00:38,375 --> 00:00:41,725
menus and we are going to start with the title screen,

17
00:00:41,720 --> 00:00:45,170
because obviously every game needs a title screen.

18
00:00:45,170 --> 00:00:50,750
So what I decided to do is to have the title screen,

19
00:00:50,750 --> 00:00:53,180
the test1, and I'm going to convert it

20
00:00:53,180 --> 00:00:56,660
into the title screen.

21
00:00:56,660 --> 00:00:58,640
Yes, reload.

22
00:00:58,640 --> 00:01:01,280
And I'm going to remove the skeleton.

23
00:01:01,279 --> 00:01:03,739
I'm only going to keep the player and

24
00:01:03,740 --> 00:01:06,170
I'll add a couple of breakable items.

25
00:01:06,170 --> 00:01:07,720
So in the prefabs.

26
00:01:07,715 --> 00:01:11,485
And let's increase the size in here just a bit.

27
00:01:11,480 --> 00:01:13,660
And where is it?

28
00:01:13,655 --> 00:01:16,655
Pickups portals, rooms.

29
00:01:17,950 --> 00:01:21,290
Okay, so a couple of breakable parts.

30
00:01:21,290 --> 00:01:26,060
So I'll add one here and another one in here,

31
00:01:26,060 --> 00:01:28,320
and another one in here.

32
00:01:28,324 --> 00:01:30,324
And just a couple of parts that we

33
00:01:30,320 --> 00:01:32,500
will have fun destroying.

34
00:01:32,495 --> 00:01:33,925
And in this menu,

35
00:01:33,920 --> 00:01:36,820
we will also have the two buttons that will

36
00:01:36,815 --> 00:01:40,235
tell us to either start the game or exit the game.

37
00:01:40,235 --> 00:01:42,425
So let's go ahead and do that.

38
00:01:42,425 --> 00:01:43,925
I'm going to right-click in here.

39
00:01:43,925 --> 00:01:46,595
I'm going to add a UI canvas,

40
00:01:46,594 --> 00:01:51,514
and this will be the main menu canvas.

41
00:01:51,515 --> 00:01:54,485
I'm going to set the event system in here.

42
00:01:54,485 --> 00:01:58,945
I'm going to make sure that it is I'm sorry,

43
00:01:58,940 --> 00:02:01,880
as screen space overlay and make sure that

44
00:02:01,880 --> 00:02:05,620
the scale will screen size.

45
00:02:05,615 --> 00:02:10,055
And there we go, 1920 by 1080.

46
00:02:10,055 --> 00:02:12,655
Hit Enter, double-click so

47
00:02:12,650 --> 00:02:14,560
we can see it properly in here.

48
00:02:14,555 --> 00:02:16,825
And what are we going to have while we

49
00:02:16,820 --> 00:02:19,360
are just going to have the screen where we move around.

50
00:02:19,355 --> 00:02:20,755
But we'll also have

51
00:02:20,750 --> 00:02:24,040
two buttons and the name of the game op here.

52
00:02:24,035 --> 00:02:28,675
So maybe we should make this a bit smaller.

53
00:02:28,670 --> 00:02:29,740
I don't know.

54
00:02:29,735 --> 00:02:31,645
I was still thinking of how

55
00:02:31,640 --> 00:02:33,320
are we going to fit all of this.

56
00:02:33,320 --> 00:02:35,270
Maybe we can try to select

57
00:02:35,270 --> 00:02:37,100
all the pots and the dome player and

58
00:02:37,100 --> 00:02:41,960
just make all the parts a bit smaller too on the scale,

59
00:02:41,960 --> 00:02:49,700
maybe make them 0.30.20 to that.

60
00:02:49,695 --> 00:02:55,925
Still small. 0.50.5? Yeah, sure.

61
00:02:55,925 --> 00:03:00,875
And then they don't player is also 0.50.5.

62
00:03:02,290 --> 00:03:05,510
So there we go. If we try to run the game

63
00:03:05,510 --> 00:03:08,970
now with our little tiny dude.

64
00:03:10,090 --> 00:03:14,470
Or as you can see, he is still very big

65
00:03:14,465 --> 00:03:16,315
and he cannot pick up the items

66
00:03:16,310 --> 00:03:18,340
because the scale is very small.

67
00:03:18,335 --> 00:03:20,395
That's because the, I just

68
00:03:20,390 --> 00:03:22,750
realized that the animations will keep him big.

69
00:03:22,745 --> 00:03:27,085
So let's bring him back to one.

70
00:03:27,080 --> 00:03:30,160
And no worries, we'll try to fit everything in here.

71
00:03:30,155 --> 00:03:31,915
So back to one.

72
00:03:31,910 --> 00:03:35,200
Save that, okay, enemies run the game.

73
00:03:35,195 --> 00:03:37,865
We will have the sprite guy.

74
00:03:37,865 --> 00:03:40,105
You will be walking around.

75
00:03:40,100 --> 00:03:42,770
He can not pick up things because in here

76
00:03:42,770 --> 00:03:45,250
we have some kind of error.

77
00:03:45,245 --> 00:03:47,095
And that's because we don't have the manager,

78
00:03:47,090 --> 00:03:49,450
we don't have an entrepreneur enter on the coin.

79
00:03:49,445 --> 00:03:51,235
There is a problem. Why is that?

80
00:03:51,230 --> 00:03:52,880
Well, because the game manager isn't

81
00:03:52,880 --> 00:03:54,790
available also on the coin.

82
00:03:54,785 --> 00:03:57,515
So we're going to stop the game.

83
00:03:57,515 --> 00:04:00,445
And we're going to select all of

84
00:04:00,440 --> 00:04:04,460
these parts and make sure that the item dropper,

85
00:04:04,460 --> 00:04:07,670
Let's just remove the component for

86
00:04:07,670 --> 00:04:11,970
now and just keep the breakable so we avoid any errors.

87
00:04:12,760 --> 00:04:18,010
So there we go, we break some pots and have fun.

88
00:04:18,005 --> 00:04:21,475
And we'll also add two keys in here to allow

89
00:04:21,470 --> 00:04:23,330
the player to select whether

90
00:04:23,330 --> 00:04:25,420
to exit or to continue the game.

91
00:04:25,415 --> 00:04:30,745
So in our screen and our canvas right here,

92
00:04:30,740 --> 00:04:34,010
I'm going to right-click select your,

93
00:04:34,010 --> 00:04:36,310
I add a text Mesh Pro.

94
00:04:36,305 --> 00:04:38,105
This will be the title.

95
00:04:38,105 --> 00:04:47,495
So game title, so time bot,

96
00:04:47,495 --> 00:04:52,405
invader, I'm not sure I want to call this may be doomed,

97
00:04:52,400 --> 00:04:55,090
bought and Vader, but let's just keep it as it is.

98
00:04:55,085 --> 00:04:58,505
Changed the font auto size,

99
00:04:58,505 --> 00:05:03,755
increase the max, and let's make it a bit bigger.

100
00:05:03,755 --> 00:05:06,545
Let's set it in the middle.

101
00:05:06,820 --> 00:05:10,340
Let's increase the max even more. So there we go.

102
00:05:10,340 --> 00:05:13,640
We need a big, huge title 40 time both

103
00:05:13,640 --> 00:05:17,810
invader to d. And we can add some underlay,

104
00:05:17,810 --> 00:05:19,420
some lightings on glow.

105
00:05:19,415 --> 00:05:21,565
So for example, we can increase the or

106
00:05:21,560 --> 00:05:23,660
the underlay and add

107
00:05:23,660 --> 00:05:26,290
a color in here to make it a bit cooler.

108
00:05:26,285 --> 00:05:28,595
So go ahead, label this,

109
00:05:28,595 --> 00:05:31,325
increase the softness, the offset on the y,

110
00:05:31,325 --> 00:05:32,635
or something like that.

111
00:05:32,630 --> 00:05:35,000
So choose the colors that you find appropriate.

112
00:05:35,000 --> 00:05:40,190
Maybe make this one red or black or antinode.

113
00:05:40,190 --> 00:05:42,140
No, black is bad.

114
00:05:42,140 --> 00:05:45,620
Let's see, maybe increase this fully

115
00:05:45,620 --> 00:05:50,250
red and on the Y, increase it up.

116
00:05:51,190 --> 00:05:53,560
So there we go. So we have

117
00:05:53,555 --> 00:05:56,365
something like a time bot and Vader 2D.

118
00:05:56,360 --> 00:05:58,310
And it's not very pretty,

119
00:05:58,310 --> 00:05:59,710
but it does its job.

120
00:05:59,705 --> 00:06:01,835
And now we're going to add two more buttons.

121
00:06:01,835 --> 00:06:04,765
So in here I'm going to right-click

122
00:06:04,760 --> 00:06:09,340
and UI and add a button.

123
00:06:09,335 --> 00:06:14,355
This is going to be the start button.

124
00:06:14,359 --> 00:06:18,079
And I'm going to move it a bit to the left.

125
00:06:18,080 --> 00:06:20,660
And this is where we decide where we want to put it.

126
00:06:20,660 --> 00:06:23,170
So because we don't have too much space,

127
00:06:23,165 --> 00:06:25,135
you can see how I'm looking at the game.

128
00:06:25,130 --> 00:06:27,670
I'm going to set them maybe right here.

129
00:06:27,665 --> 00:06:29,785
Let's see if we run the game.

130
00:06:29,780 --> 00:06:31,130
How does that look?

131
00:06:31,130 --> 00:06:32,840
So having a button down here,

132
00:06:32,840 --> 00:06:34,480
no, I think that's not bad.

133
00:06:34,475 --> 00:06:36,275
That's not bad at all.

134
00:06:36,275 --> 00:06:39,635
So I'm going to maybe increase the size.

135
00:06:39,634 --> 00:06:41,284
And in the resources.

136
00:06:41,285 --> 00:06:43,405
We can go in here and you can find

137
00:06:43,400 --> 00:06:45,920
the menu elements that I've provided you with.

138
00:06:45,920 --> 00:06:47,560
So these are the buttons.

139
00:06:47,555 --> 00:06:51,385
So back in our sprites, let's see,

140
00:06:51,380 --> 00:06:53,810
do we have something under the UI elements,

141
00:06:53,810 --> 00:06:59,960
UI elements and right-click, create 140 buttons.

142
00:06:59,960 --> 00:07:02,210
Open this up, and let's

143
00:07:02,210 --> 00:07:05,600
drag the buttons all the way into Unity.

144
00:07:05,600 --> 00:07:07,490
And let's see what we have in here.

145
00:07:07,490 --> 00:07:12,760
And let's go to multiple lie Sprite Editor.

146
00:07:12,755 --> 00:07:14,795
That's slice these babies up.

147
00:07:14,795 --> 00:07:16,585
There we go. So these are perfectly

148
00:07:16,580 --> 00:07:18,490
sliced with the shadows.

149
00:07:18,485 --> 00:07:20,095
So apply the changes.

150
00:07:20,090 --> 00:07:21,860
Now we have these and I'm

151
00:07:21,860 --> 00:07:23,480
going to select the Start button.

152
00:07:23,480 --> 00:07:24,910
And as you can see, we have

153
00:07:24,905 --> 00:07:27,815
the normal React component that we are used to.

154
00:07:27,815 --> 00:07:29,495
And we have also the image

155
00:07:29,495 --> 00:07:31,525
and the button things right here.

156
00:07:31,520 --> 00:07:34,580
And you can add an on-click event on this button.

157
00:07:34,580 --> 00:07:37,910
Whenever it's clicked, you can change the way it behaves.

158
00:07:37,910 --> 00:07:39,920
So if the normal color, for example,

159
00:07:39,920 --> 00:07:42,920
can be completely black or white or red or whatever,

160
00:07:42,920 --> 00:07:44,810
you can change the highlighted color.

161
00:07:44,810 --> 00:07:48,140
So for example, if we move our mouse over this button,

162
00:07:48,140 --> 00:07:52,490
a free press the button and becomes, for example, green.

163
00:07:52,490 --> 00:07:54,710
And if we select, I don't know,

164
00:07:54,710 --> 00:07:56,750
selected color, I'm not sure what that is.

165
00:07:56,750 --> 00:07:58,180
So if I run the game right now,

166
00:07:58,175 --> 00:07:59,515
you'll notice that if I move

167
00:07:59,510 --> 00:08:01,210
over the button and becomes red,

168
00:08:01,205 --> 00:08:03,355
once I click it, it becomes green.

169
00:08:03,350 --> 00:08:05,390
So this is how buttons work.

170
00:08:05,390 --> 00:08:08,050
You can play around with a lot of things in here.

171
00:08:08,045 --> 00:08:09,745
But what I want to focus on is

172
00:08:09,740 --> 00:08:11,470
changing the sprite source.

173
00:08:11,465 --> 00:08:15,635
And let's see what kind of buttons we have in here.

174
00:08:15,635 --> 00:08:20,275
So something not good happened in the Sprite Editor.

175
00:08:20,270 --> 00:08:22,520
And how many sprites do we have?

176
00:08:22,520 --> 00:08:26,060
1, 2, 3, what are these empty things in here?

177
00:08:26,060 --> 00:08:29,140
I don't like the looks of this, but anyways,

178
00:08:29,135 --> 00:08:32,305
let's try to add this button. There we go.

179
00:08:32,300 --> 00:08:34,850
So you can see this is the button that we've added.

180
00:08:34,850 --> 00:08:37,760
Let's try to set it may be to

181
00:08:37,760 --> 00:08:41,660
native size or maybe increase it on the Y.

182
00:08:41,660 --> 00:08:43,930
So there we go. We can set two buttons

183
00:08:43,925 --> 00:08:46,415
on each side of the title screen.

184
00:08:46,415 --> 00:08:48,745
And maybe you can add a different kind of button,

185
00:08:48,740 --> 00:08:51,130
may be this one which is a bit more clear.

186
00:08:51,125 --> 00:08:52,385
I think it's better.

187
00:08:52,385 --> 00:08:54,145
So now when we run the game,

188
00:08:54,140 --> 00:08:55,480
you can see that we have

189
00:08:55,475 --> 00:08:57,445
a really nice looking button and it

190
00:08:57,440 --> 00:08:59,770
even changes color when we press it.

191
00:08:59,765 --> 00:09:02,905
And maybe you don't want to have that kind of thing.

192
00:09:02,900 --> 00:09:05,240
Maybe the only thing that you might want

193
00:09:05,240 --> 00:09:08,530
to have is not to have this pressed.

194
00:09:08,525 --> 00:09:10,165
Maybe we can make it darker or

195
00:09:10,160 --> 00:09:12,140
something or keep it as it is,

196
00:09:12,140 --> 00:09:15,020
but just change the alpha on it,

197
00:09:15,020 --> 00:09:16,220
which is also a good idea,

198
00:09:16,220 --> 00:09:19,190
but I'm going to make sure to have it some kind of

199
00:09:19,190 --> 00:09:20,680
green color just so we know that

200
00:09:20,675 --> 00:09:22,445
we are pressing this button.

201
00:09:22,445 --> 00:09:24,505
And now with that we have the start button.

202
00:09:24,500 --> 00:09:27,970
Let's duplicate this and move it to the left.

203
00:09:27,965 --> 00:09:30,085
And this will be the exit button.

204
00:09:30,080 --> 00:09:35,020
So Exit button.

205
00:09:35,015 --> 00:09:37,795
And now what we need to do or you know what?

206
00:09:37,790 --> 00:09:40,210
Maybe I did this too soon.

207
00:09:40,205 --> 00:09:41,725
That's just delete the X button

208
00:09:41,720 --> 00:09:43,400
because we want to change the text.

209
00:09:43,400 --> 00:09:46,000
And here you can see that we have button texts.

210
00:09:45,995 --> 00:09:48,035
We don't want this text.

211
00:09:48,035 --> 00:09:49,135
We deleted.

212
00:09:49,130 --> 00:09:50,570
We will add our own text,

213
00:09:50,570 --> 00:09:52,660
which is a text Mesh Pro.

214
00:09:52,655 --> 00:09:57,655
And obviously we're going to make it the cyborg bold.

215
00:09:57,650 --> 00:10:00,520
The auto size, increased demands,

216
00:10:00,515 --> 00:10:02,645
set it in the middle.

217
00:10:02,645 --> 00:10:06,505
And that's all, that's all that we need to do.

218
00:10:06,500 --> 00:10:10,900
And I'm going to increase the size of this one.

219
00:10:10,895 --> 00:10:15,445
So let's make it a bit bigger and set it in

220
00:10:15,440 --> 00:10:21,580
the middle and just make sure that it fits properly.

221
00:10:21,575 --> 00:10:24,715
Now the only thing that might bother us

222
00:10:24,710 --> 00:10:28,900
here is that the when,

223
00:10:28,895 --> 00:10:30,355
when we tried to change, for example,

224
00:10:30,350 --> 00:10:33,070
the color of this one.

225
00:10:33,065 --> 00:10:35,305
Oh no, no, everything is working.

226
00:10:35,300 --> 00:10:36,920
So should we make it dark?

227
00:10:36,920 --> 00:10:39,320
I think dark. That's first of all,

228
00:10:39,320 --> 00:10:42,740
try to type the name, so start came.

229
00:10:42,740 --> 00:10:44,900
Okay, so apparently, having it

230
00:10:44,900 --> 00:10:47,600
completely dark is not the way to go.

231
00:10:47,600 --> 00:10:49,250
What colors should we be choosing?

232
00:10:49,250 --> 00:10:51,340
Maybe even we should remove the underlay.

233
00:10:51,335 --> 00:10:54,065
But if we remove the underlay in here,

234
00:10:54,065 --> 00:10:56,365
remove also the underlay up here.

235
00:10:56,360 --> 00:10:59,270
So this is why sometimes I don't like to use

236
00:10:59,270 --> 00:11:02,450
text Mesh probe because everything is kind of related.

237
00:11:02,450 --> 00:11:04,760
We are changing the entire shader

238
00:11:04,760 --> 00:11:07,150
of what detects mesh Pro is.

239
00:11:07,145 --> 00:11:11,335
Shaders are a whole different breed of information.

240
00:11:11,330 --> 00:11:13,900
So I'm not going to delve too deep into that.

241
00:11:13,895 --> 00:11:15,425
So back in Unity.

242
00:11:15,425 --> 00:11:17,575
And let's see how that looks.

243
00:11:17,570 --> 00:11:19,900
If I run the game, is it visible?

244
00:11:19,895 --> 00:11:23,275
So start the game and not very much.

245
00:11:23,270 --> 00:11:24,560
When it becomes red,

246
00:11:24,560 --> 00:11:26,090
it is more visible.

247
00:11:26,090 --> 00:11:29,120
Maybe we can change the background of the button.

248
00:11:29,120 --> 00:11:30,800
So I'm just playing around honestly,

249
00:11:30,800 --> 00:11:32,200
I'm not sure what I'm doing.

250
00:11:32,195 --> 00:11:34,735
I'm just testing things out just as you are.

251
00:11:34,730 --> 00:11:38,030
No, I think this one is better for our start game.

252
00:11:38,030 --> 00:11:40,640
And now that we have this one,

253
00:11:40,640 --> 00:11:41,960
now we can duplicate,

254
00:11:41,960 --> 00:11:45,850
call it the Exit button.

255
00:11:45,845 --> 00:11:48,835
And let's move it to the side.

256
00:11:48,830 --> 00:11:52,310
On the other side. And in here we are going to change

257
00:11:52,310 --> 00:11:56,180
the text to access that.

258
00:11:56,180 --> 00:11:59,470
Again. Hit Enter. There we go.

259
00:11:59,470 --> 00:12:01,060
So now we have two buttons.

260
00:12:01,060 --> 00:12:02,430
We have set up the menu.

261
00:12:02,425 --> 00:12:04,905
We can walk around, we can destroy these things,

262
00:12:04,900 --> 00:12:06,960
we can shoot around us.

263
00:12:06,955 --> 00:12:10,265
We're using the very scary buttons.

264
00:12:10,269 --> 00:12:13,719
There we go. And we can start the game, exit the game.

265
00:12:13,720 --> 00:12:15,310
But as you can see, they do not

266
00:12:15,310 --> 00:12:17,430
do anything right now and again.

267
00:12:17,425 --> 00:12:19,095
So what we're going to do is add

268
00:12:19,090 --> 00:12:21,190
a couple of functionalities to these.

269
00:12:21,190 --> 00:12:24,550
So I'm going to go into the scripts.

270
00:12:24,550 --> 00:12:26,530
I'm going to right-click and

271
00:12:26,530 --> 00:12:29,930
create a folder for the menu.

272
00:12:29,934 --> 00:12:32,384
Double-click in here, right-click and

273
00:12:32,380 --> 00:12:34,270
create a C sharp script for

274
00:12:34,270 --> 00:12:39,240
the Main Menu Manager.

275
00:12:39,235 --> 00:12:40,665
And let's just call it menu,

276
00:12:40,665 --> 00:12:42,445
main menu because we would have to add it

277
00:12:42,440 --> 00:12:44,480
to the Main Menu Manager if we did.

278
00:12:44,480 --> 00:12:45,910
What's the problem here?

279
00:12:45,905 --> 00:12:51,755
We have a problem with the sound effects, I think.

280
00:12:51,754 --> 00:12:54,784
Yeah, I think it's a problem with the sound effects.

281
00:12:54,785 --> 00:12:56,455
The problem with a couple of things.

282
00:12:56,450 --> 00:12:58,700
There are a lot of problems in here because we

283
00:12:58,700 --> 00:13:01,070
didn't add all the manager and all of that stuff,

284
00:13:01,070 --> 00:13:03,130
but we don't really care about it.

285
00:13:03,125 --> 00:13:04,645
This will not be a problem

286
00:13:04,640 --> 00:13:06,380
because we are not actually doing anything.

287
00:13:06,380 --> 00:13:07,760
And at this level,

288
00:13:07,760 --> 00:13:09,440
so now was the main menu.

289
00:13:09,440 --> 00:13:11,680
Let's add it to the main menu canvas.

290
00:13:11,675 --> 00:13:14,395
And let's double-click and open up the script right here.

291
00:13:14,390 --> 00:13:16,490
So we are going to first of

292
00:13:16,490 --> 00:13:19,010
all create a method for the exit game.

293
00:13:19,010 --> 00:13:24,100
So public void exit game.

294
00:13:24,095 --> 00:13:26,035
And because we are still in

295
00:13:26,030 --> 00:13:28,700
the editor and have not implemented the game,

296
00:13:28,700 --> 00:13:30,340
this will not be working.

297
00:13:30,335 --> 00:13:33,685
But if we write application dot close,

298
00:13:33,680 --> 00:13:36,800
I mean the application taught quit.

299
00:13:36,800 --> 00:13:39,410
This will exit from the application

300
00:13:39,410 --> 00:13:41,300
and quits the player application.

301
00:13:41,300 --> 00:13:43,550
And as you can see, but because we are

302
00:13:43,550 --> 00:13:46,120
in the game mode of the Unity editor,

303
00:13:46,115 --> 00:13:47,395
this will not work.

304
00:13:47,390 --> 00:13:51,490
So what we'll do is we'll just add a debug dot log.

305
00:13:51,485 --> 00:13:57,865
And we'll say that we exited the game.

306
00:13:57,860 --> 00:14:00,500
Trust me, when you do build this game,

307
00:14:00,500 --> 00:14:01,870
this button will work.

308
00:14:01,865 --> 00:14:05,255
Don't worry about it. Anyways, this will run the game.

309
00:14:05,255 --> 00:14:08,455
And if we go back into Unity,

310
00:14:08,450 --> 00:14:11,020
if we go to the exit button,

311
00:14:11,015 --> 00:14:14,275
we can scroll down in here and in the onclick event,

312
00:14:14,270 --> 00:14:17,890
we can press this Plus button and we can add,

313
00:14:17,885 --> 00:14:19,735
first of all, an object which

314
00:14:19,730 --> 00:14:22,060
we will access the functions of.

315
00:14:22,055 --> 00:14:24,415
So if I add the main menu,

316
00:14:24,410 --> 00:14:26,330
you'll notice that now I can access

317
00:14:26,330 --> 00:14:28,640
functions and one of those functions.

318
00:14:28,640 --> 00:14:30,140
So for example, I can access

319
00:14:30,140 --> 00:14:32,180
game object and do a couple of things in here.

320
00:14:32,180 --> 00:14:34,510
Maybe turn off the game object, direct,

321
00:14:34,505 --> 00:14:37,445
transform, change name, and so on and so forth.

322
00:14:37,445 --> 00:14:40,745
But I can also access the main menu.

323
00:14:40,745 --> 00:14:42,715
And you can see here I have Canvas, canvas,

324
00:14:42,710 --> 00:14:44,710
scaler, graphic, ray caster,

325
00:14:44,705 --> 00:14:48,115
and all of these are components inside of

326
00:14:48,110 --> 00:14:50,480
the main menu canvas that I've provided

327
00:14:50,480 --> 00:14:54,230
the button with at it also contains the main menu.

328
00:14:54,230 --> 00:14:55,760
So on the main menu,

329
00:14:55,760 --> 00:14:57,530
I'm going to select it.

330
00:14:57,530 --> 00:14:58,850
And you can see that I have

331
00:14:58,850 --> 00:15:01,070
a lot of methods that I can use.

332
00:15:01,070 --> 00:15:04,340
And one of them is the exit game that I just created.

333
00:15:04,340 --> 00:15:08,420
So when I click on this one, I run the game.

334
00:15:08,420 --> 00:15:11,140
I can walk around and do the things I do.

335
00:15:11,135 --> 00:15:13,375
And then if I click on the exit game,

336
00:15:13,370 --> 00:15:15,920
you'll notice that we exited the game.

337
00:15:15,920 --> 00:15:17,780
Why we capitalize, I don't know,

338
00:15:17,780 --> 00:15:19,850
but you can see that this button

339
00:15:19,850 --> 00:15:22,300
actually works and I can press it.

340
00:15:22,295 --> 00:15:25,625
So now it's time to create the start game method,

341
00:15:25,625 --> 00:15:28,325
and that is going to be your challenge.

342
00:15:28,325 --> 00:15:29,755
So set the scene and

343
00:15:29,750 --> 00:15:31,960
the building index as the first scene

344
00:15:31,955 --> 00:15:35,665
and the first-level to be the second scene.

345
00:15:35,660 --> 00:15:37,430
So you remember the building decks.

346
00:15:37,430 --> 00:15:40,250
If you don't, you'll need to go ahead and check it.

347
00:15:40,250 --> 00:15:43,510
It's in the File Build Settings, I believe.

348
00:15:43,505 --> 00:15:44,585
Yep. Yes.

349
00:15:44,585 --> 00:15:46,975
So we need to start the game.

350
00:15:46,970 --> 00:15:48,140
In order to start the game,

351
00:15:48,140 --> 00:15:49,880
we need to load the first level.

352
00:15:49,880 --> 00:15:51,710
To load the first level, obviously,

353
00:15:51,710 --> 00:15:53,590
we need to have a scene manager

354
00:15:53,585 --> 00:15:54,835
and all of that good stuff.

355
00:15:54,830 --> 00:15:56,740
I hope you didn't forget how to do that.

356
00:15:56,735 --> 00:15:58,955
It was a couple of sections ago.

357
00:15:58,955 --> 00:16:00,655
Create the start game method,

358
00:16:00,650 --> 00:16:01,750
make sure it's public.

359
00:16:01,745 --> 00:16:04,015
And the method access the scene manager and

360
00:16:04,010 --> 00:16:06,590
get the build settings of the current active seen.

361
00:16:06,590 --> 00:16:09,640
And then you'll need to increase it by one.

362
00:16:09,635 --> 00:16:11,525
And just as a small hint,

363
00:16:11,525 --> 00:16:13,255
You need to access the scene manager,

364
00:16:13,250 --> 00:16:17,000
get active scene and build index plus one.

365
00:16:17,000 --> 00:16:18,760
So with that out of the way,

366
00:16:18,755 --> 00:16:24,305
pause the video right now and go do the alone.

367
00:16:24,400 --> 00:16:26,630
Okay, welcome back.

368
00:16:26,630 --> 00:16:29,570
So first of all, let me remove the start and update.

369
00:16:29,570 --> 00:16:32,150
I'm not sure we'll be ever using them.

370
00:16:32,150 --> 00:16:34,360
And here I'm going to add

371
00:16:34,355 --> 00:16:37,285
in the engine dot senior management.

372
00:16:37,280 --> 00:16:41,550
And now I'm going to create a public void.

373
00:16:41,550 --> 00:16:47,620
Void star game should

374
00:16:47,620 --> 00:16:51,840
be capitalized and this one should not start game.

375
00:16:51,835 --> 00:16:54,285
That's opened up the squiggly lines.

376
00:16:54,280 --> 00:16:56,170
And in here I'm going to access

377
00:16:56,170 --> 00:17:01,080
the scene manager dot load seen.

378
00:17:01,075 --> 00:17:02,925
And what scene should I be loading?

379
00:17:02,920 --> 00:17:04,360
Well, first of all,

380
00:17:04,360 --> 00:17:07,900
let's go to the File Build Settings.

381
00:17:07,900 --> 00:17:10,330
And the title screen is already the first one.

382
00:17:10,330 --> 00:17:13,000
So what I want to do as I want to get the index

383
00:17:13,000 --> 00:17:16,080
of this one and then increase it by one.

384
00:17:16,075 --> 00:17:21,285
So I'm going to go ahead and get this scene.

385
00:17:21,280 --> 00:17:26,690
Manager dot, get active scene.

386
00:17:26,690 --> 00:17:28,700
And in here I'm going to get

387
00:17:28,700 --> 00:17:32,050
the build index and I'm just going to increase it by one.

388
00:17:32,045 --> 00:17:35,165
So we go immediately to the next scene.

389
00:17:35,165 --> 00:17:36,485
Save that.

390
00:17:36,485 --> 00:17:39,035
Now let's go back into our game.

391
00:17:39,035 --> 00:17:41,045
And let's see if that works.

392
00:17:41,045 --> 00:17:44,135
So I'm going to run again.

393
00:17:44,320 --> 00:17:47,120
We walk around, we destroy things,

394
00:17:47,120 --> 00:17:48,760
we exit the game, it doesn't work.

395
00:17:48,755 --> 00:17:50,185
Start the game.

396
00:17:50,180 --> 00:17:52,790
And it doesn't work because we have not

397
00:17:52,790 --> 00:17:55,730
assigned how smart of us,

398
00:17:55,730 --> 00:17:56,840
we have not assigned

399
00:17:56,840 --> 00:17:59,530
the stop button to do anything at all.

400
00:17:59,525 --> 00:18:02,215
So main menu, how many times will I make

401
00:18:02,210 --> 00:18:06,760
this mistake until we finally save that? Run the game.

402
00:18:06,755 --> 00:18:10,385
Let's start again.

403
00:18:10,385 --> 00:18:13,755
There we go. So now we are on the first level.

404
00:18:13,759 --> 00:18:15,259
How cool is that? And we know it's

405
00:18:15,260 --> 00:18:16,400
the first level because we

406
00:18:16,400 --> 00:18:17,980
have all the skeletons in here.

407
00:18:17,975 --> 00:18:22,175
See, even though we didn't do any changes to this level,

408
00:18:22,175 --> 00:18:25,165
but because we've changed the prefabs of the skeleton,

409
00:18:25,160 --> 00:18:27,110
they can now pick things up.

410
00:18:27,110 --> 00:18:28,430
Obviously, there is a couple

411
00:18:28,430 --> 00:18:29,950
of things that we need to change.

412
00:18:29,945 --> 00:18:32,915
But for now, we know that the start game works,

413
00:18:32,915 --> 00:18:34,135
the exit game works.

414
00:18:34,130 --> 00:18:36,010
We've created a title screen.

415
00:18:36,005 --> 00:18:37,435
We are going to commit

416
00:18:37,430 --> 00:18:40,490
our changes and we are going to see you or actually,

417
00:18:40,490 --> 00:18:44,340
I'm going to see you in the next video.

