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

2
00:00:03,555 --> 00:00:05,895
In this video, we don't do much,

3
00:00:05,895 --> 00:00:11,735
but we do understand something or a series of methods and

4
00:00:11,730 --> 00:00:15,170
dissections of strings that is very complicated but

5
00:00:15,165 --> 00:00:19,475
extremely necessary for our case in order to continue on.

6
00:00:19,470 --> 00:00:23,370
So let's not waste any more time and let's get started.

7
00:00:23,370 --> 00:00:26,010
This is one of the more technical videos,

8
00:00:26,010 --> 00:00:29,040
I believe, and the entire series on the entire course.

9
00:00:29,040 --> 00:00:32,130
So I need your full concentration.

10
00:00:32,130 --> 00:00:33,690
O k.

11
00:00:33,690 --> 00:00:37,290
So now we have the waves being completed.

12
00:00:37,285 --> 00:00:39,955
We have the levels or

13
00:00:39,950 --> 00:00:41,810
the potential levels that we want to

14
00:00:41,810 --> 00:00:43,940
go kind of being setup.

15
00:00:43,940 --> 00:00:47,230
Now it's time to take it to the next level and get it,

16
00:00:47,225 --> 00:00:49,345
take it the next level and actually

17
00:00:49,340 --> 00:00:51,770
start displaying the names of

18
00:00:51,770 --> 00:00:56,560
the levels that we can go to right here on the doors.

19
00:00:56,555 --> 00:00:58,175
So what I'm going to do is

20
00:00:58,175 --> 00:01:00,065
I'm going to go to the door one,

21
00:01:00,065 --> 00:01:02,665
I'm going to right-click in here and I'm going

22
00:01:02,660 --> 00:01:05,590
to create a UI canvas for this door.

23
00:01:05,585 --> 00:01:08,225
So where's the UI canvas?

24
00:01:08,225 --> 00:01:10,235
There we go, the canvas.

25
00:01:10,235 --> 00:01:11,785
And if I open this up,

26
00:01:11,780 --> 00:01:19,640
this will be the text display Canvas.

27
00:01:19,635 --> 00:01:22,665
And if I go into this canvas and you

28
00:01:22,660 --> 00:01:25,810
see what is the door have, okay, so, great.

29
00:01:25,810 --> 00:01:28,480
And the canvas right here,

30
00:01:28,480 --> 00:01:31,010
I'm going to select world space.

31
00:01:31,014 --> 00:01:35,234
And I'm going to double-click to see the whole canvas.

32
00:01:35,230 --> 00:01:36,550
We are going to scale it down to

33
00:01:36,550 --> 00:01:40,680
0.001 on the x and on the y.

34
00:01:40,675 --> 00:01:44,185
And I'm going to reset the position to be at 0, 0.

35
00:01:44,185 --> 00:01:47,415
Now when we double-click, it's very small.

36
00:01:47,410 --> 00:01:49,450
So we need to make

37
00:01:49,450 --> 00:01:53,610
this one without a 0 and this one without a 0.

38
00:01:53,605 --> 00:01:57,795
And or maybe do add a 0,

39
00:01:57,790 --> 00:02:02,270
but make this one a2.

40
00:02:02,265 --> 00:02:03,855
Oh, a five.

41
00:02:03,859 --> 00:02:05,499
Yep, seems good.

42
00:02:05,495 --> 00:02:10,745
And this 15, maybe we should make this bigger.

43
00:02:10,745 --> 00:02:14,395
Let's make in an eight and this one.

44
00:02:14,390 --> 00:02:16,400
And it also, yeah,

45
00:02:16,400 --> 00:02:19,760
so I think it's pretty good, pretty solid.

46
00:02:19,759 --> 00:02:21,889
So in here we are going to be adding

47
00:02:21,890 --> 00:02:24,370
the texts that we will want to be displaying.

48
00:02:24,365 --> 00:02:26,075
And what will this TextView displaying?

49
00:02:26,075 --> 00:02:29,545
It will be displaying the level that you would be able to

50
00:02:29,540 --> 00:02:33,580
go to once you open this particular door.

51
00:02:33,575 --> 00:02:37,545
So I'm going to go ahead and apply the changes.

52
00:02:37,549 --> 00:02:40,519
And when I do apply the changes to lower one,

53
00:02:40,520 --> 00:02:44,420
you'll notice that the door to also has its own Canvas

54
00:02:44,420 --> 00:02:46,780
now and all other subsequent doors

55
00:02:46,775 --> 00:02:48,775
should also have these campuses.

56
00:02:48,770 --> 00:02:50,900
So I'm going to keep working in here.

57
00:02:50,900 --> 00:02:55,190
I'm going to right-click and the UI canvas and I'm

58
00:02:55,190 --> 00:02:59,480
going to add a text Mesh Pro.

59
00:02:59,480 --> 00:03:00,800
So a text Mesh Pro,

60
00:03:00,800 --> 00:03:04,630
this will be the level name.

61
00:03:04,625 --> 00:03:09,685
Hit Enter, and let's go ahead and make it a bit bigger.

62
00:03:09,680 --> 00:03:12,290
Let's put it up here or you know what?

63
00:03:12,290 --> 00:03:15,230
Let's put the level name under and

64
00:03:15,230 --> 00:03:18,380
the duplicate this one and add it in here.

65
00:03:18,380 --> 00:03:26,780
And this will simply read for us to open door.

66
00:03:26,780 --> 00:03:31,240
And let's change the everything.

67
00:03:31,235 --> 00:03:35,245
Well, everything that we're always doing, auto size, max,

68
00:03:35,240 --> 00:03:40,060
level, color, and for some reason I cannot see it.

69
00:03:40,055 --> 00:03:42,605
Why can I not see it?

70
00:03:42,605 --> 00:03:44,395
Shouldn't be the level name,

71
00:03:44,390 --> 00:03:49,730
this should be the open text enter.

72
00:03:49,730 --> 00:03:51,380
What's the problem?

73
00:03:51,380 --> 00:03:52,970
If I move it in here,

74
00:03:52,970 --> 00:03:55,740
but it's not displaying and here.

75
00:03:56,470 --> 00:04:02,840
And if I open the Canvas sorting layer,

76
00:04:02,840 --> 00:04:04,250
set on the player,

77
00:04:04,250 --> 00:04:05,510
so there we go.

78
00:04:05,510 --> 00:04:08,630
So I've set the sorting layer to be on the layer

79
00:04:08,630 --> 00:04:12,140
and because I have the front in here,

80
00:04:12,140 --> 00:04:13,550
I'm going to just make it one to

81
00:04:13,550 --> 00:04:15,470
make everything a little bit better.

82
00:04:15,470 --> 00:04:16,750
Okay?

83
00:04:16,745 --> 00:04:18,955
So I change the sorting layer of

84
00:04:18,950 --> 00:04:20,540
the actual canvas right here

85
00:04:20,540 --> 00:04:22,370
you can see I sell it onto player.

86
00:04:22,370 --> 00:04:24,940
And I've been saying since the beginning,

87
00:04:24,935 --> 00:04:27,085
we need to set new layers.

88
00:04:27,080 --> 00:04:28,310
I haven't done that.

89
00:04:28,310 --> 00:04:29,290
Maybe you did.

90
00:04:29,285 --> 00:04:30,215
That's better.

91
00:04:30,215 --> 00:04:32,335
You are progressing faster than me.

92
00:04:32,330 --> 00:04:34,220
So press E to open the door.

93
00:04:34,220 --> 00:04:41,760
And in here this will be the text level, level name.

94
00:04:42,160 --> 00:04:46,310
And let's change this also.

95
00:04:46,310 --> 00:04:51,460
Sell it to bold size, max.

96
00:04:51,455 --> 00:04:55,025
And okay, great, So we'll save that.

97
00:04:55,025 --> 00:04:57,235
We're going to go to the door and we're going

98
00:04:57,230 --> 00:04:59,780
to apply the changes. And there we go.

99
00:04:59,780 --> 00:05:02,030
So now you can see that this one also has

100
00:05:02,030 --> 00:05:05,770
its own level name and press the E key to open the door.

101
00:05:05,765 --> 00:05:08,825
So now what are we actually going to do?

102
00:05:08,825 --> 00:05:11,345
We want to get the level name,

103
00:05:11,345 --> 00:05:14,315
which should be a string and this plate right here.

104
00:05:14,315 --> 00:05:15,725
But as you remember.

105
00:05:15,724 --> 00:05:17,064
The level of exit,

106
00:05:17,060 --> 00:05:18,730
where is it an exit?

107
00:05:18,725 --> 00:05:20,785
We change this to an integer.

108
00:05:20,780 --> 00:05:22,880
So how are we actually

109
00:05:22,880 --> 00:05:25,780
going to do this in here and start?

110
00:05:25,775 --> 00:05:28,025
I'm going to create the start.

111
00:05:28,025 --> 00:05:30,605
And now you need to focus a lot,

112
00:05:30,605 --> 00:05:32,125
but don't worry, everything will

113
00:05:32,120 --> 00:05:34,310
be slowly but surely explained.

114
00:05:34,310 --> 00:05:36,940
So first of all, I'm going to create a string

115
00:05:36,935 --> 00:05:40,355
variable which is going to be the scene path.

116
00:05:40,355 --> 00:05:46,505
And this path will be equal to seen utility.

117
00:05:46,505 --> 00:05:52,225
Seen utility, but obviously we cannot use it.

118
00:05:52,220 --> 00:05:57,650
So I'm going to add in here the senior management.

119
00:05:57,650 --> 00:06:02,090
And now we should have access to the scene utility.

120
00:06:02,090 --> 00:06:05,450
And then from the same utility I'm going to get seen

121
00:06:05,450 --> 00:06:09,140
path can see right here by the build index.

122
00:06:09,140 --> 00:06:12,010
So now I can add this right here,

123
00:06:12,005 --> 00:06:15,355
and I can say the level to load.

124
00:06:15,350 --> 00:06:16,870
Save that.

125
00:06:16,865 --> 00:06:18,725
So what will this give us?

126
00:06:18,725 --> 00:06:22,045
I'm just going to go ahead and print this out in here.

127
00:06:22,040 --> 00:06:28,470
So I will say print out the scene path.

128
00:06:29,020 --> 00:06:37,850
And let's just seen path concatenated. Save that.

129
00:06:37,850 --> 00:06:39,380
And before I move on,

130
00:06:39,380 --> 00:06:40,730
there is something that we

131
00:06:40,730 --> 00:06:42,730
probably should have done and that is

132
00:06:42,725 --> 00:06:46,945
actually using the level exit one and level exit to two,

133
00:06:46,940 --> 00:06:48,890
assigned the level to go.

134
00:06:48,890 --> 00:06:55,650
So level manager and where are the level exits?

135
00:06:56,200 --> 00:06:58,220
Waves?

136
00:06:58,220 --> 00:07:00,970
We have spawns 0,

137
00:07:00,965 --> 00:07:02,755
so they aren't in here.

138
00:07:02,750 --> 00:07:06,150
And I'm going to select the portals.

139
00:07:06,154 --> 00:07:08,764
So portal has this one.

140
00:07:08,765 --> 00:07:10,705
So which one has the first portal?

141
00:07:10,700 --> 00:07:13,160
This one and the second portal will

142
00:07:13,160 --> 00:07:16,540
be the second one on the level manager.

143
00:07:16,535 --> 00:07:19,075
So there we go, we save that.

144
00:07:19,070 --> 00:07:22,160
So now we have access to both the portals.

145
00:07:22,160 --> 00:07:25,360
And now we can go back in here,

146
00:07:25,355 --> 00:07:27,785
slide down and the level manager.

147
00:07:27,785 --> 00:07:30,395
And after we get the level of exit,

148
00:07:30,395 --> 00:07:33,475
one dot on the level exit,

149
00:07:33,470 --> 00:07:35,480
we can either assign it immediately,

150
00:07:35,480 --> 00:07:36,830
call this public, or we can

151
00:07:36,830 --> 00:07:38,660
create a small method in here,

152
00:07:38,660 --> 00:07:44,240
which we'll say that it's a public void.

153
00:07:44,240 --> 00:07:52,220
And we'll make it set the level to load.

154
00:07:52,220 --> 00:07:59,810
And this will be the level two load.

155
00:07:59,810 --> 00:08:03,460
Or let's just make it level.

156
00:08:03,455 --> 00:08:05,195
So shortcut it.

157
00:08:05,195 --> 00:08:08,155
And in here we're just going to say that the level

158
00:08:08,150 --> 00:08:11,960
to low level looped.

159
00:08:11,960 --> 00:08:14,750
Save that back in

160
00:08:14,750 --> 00:08:19,430
the level manager that set level to load.

161
00:08:19,430 --> 00:08:22,370
And it's going to be the level 1.

162
00:08:22,370 --> 00:08:25,010
And then in here we're going to set

163
00:08:25,010 --> 00:08:34,060
the level x2 dot set level to low level to go to two.

164
00:08:34,055 --> 00:08:35,465
Excellent.

165
00:08:35,465 --> 00:08:37,595
So now we should have

166
00:08:37,595 --> 00:08:41,665
this level to load being except right here.

167
00:08:41,660 --> 00:08:44,330
And I'm just going to show you what

168
00:08:44,330 --> 00:08:46,790
we are going to get displayed on the screen.

169
00:08:46,790 --> 00:08:49,440
So when we run the game,

170
00:08:49,660 --> 00:08:52,310
we should see right here in

171
00:08:52,310 --> 00:08:54,320
the console, Let's pause that.

172
00:08:54,320 --> 00:08:56,380
And the console we shall see

173
00:08:56,375 --> 00:09:00,205
the scene path asset scenes style screen.

174
00:09:00,200 --> 00:09:03,740
So obviously, this is the path that we

175
00:09:03,740 --> 00:09:07,360
are getting sent and this is the current level to load.

176
00:09:07,355 --> 00:09:09,425
And what does the current level that we're on?

177
00:09:09,425 --> 00:09:11,465
It's currently being set as 0.

178
00:09:11,465 --> 00:09:15,385
So 0, if we look in the settings in here,

179
00:09:15,380 --> 00:09:18,010
you can see that 0 is the title screen,

180
00:09:18,005 --> 00:09:21,385
so you can see how the scene path was being displayed.

181
00:09:21,380 --> 00:09:25,100
So our goal is to remove everything and just keep

182
00:09:25,100 --> 00:09:27,770
the title screen and have it being

183
00:09:27,770 --> 00:09:30,890
displayed right here under the door name.

184
00:09:30,890 --> 00:09:32,750
So that's what we're going to do.

185
00:09:32,750 --> 00:09:33,950
If I go back in here,

186
00:09:33,950 --> 00:09:35,600
let's remove the print.

187
00:09:35,600 --> 00:09:37,840
And now this is the scary part.

188
00:09:37,835 --> 00:09:41,725
I'm going to say that the integer is

189
00:09:41,720 --> 00:09:45,860
the last slash and it's

190
00:09:45,860 --> 00:09:51,540
equal to the scene path dot last index of.

191
00:09:52,600 --> 00:09:55,190
And use this forward slash.

192
00:09:55,190 --> 00:09:58,240
Actually it's between a single quotation.

193
00:09:58,235 --> 00:10:00,175
So what happens in here?

194
00:10:00,170 --> 00:10:05,570
Let's again print and, or know what.

195
00:10:05,570 --> 00:10:06,710
Let's continue on and you'll

196
00:10:06,710 --> 00:10:09,200
understand easily what that means.

197
00:10:09,200 --> 00:10:12,140
So string name and

198
00:10:12,140 --> 00:10:15,110
it's going to be equal to the same path

199
00:10:15,110 --> 00:10:25,980
substring last slash and plus 1, 0 plus 1.

200
00:10:26,290 --> 00:10:30,880
And let's try to print the name and see what we get.

201
00:10:30,875 --> 00:10:34,705
So you can see the last index substring,

202
00:10:34,700 --> 00:10:36,890
and then we are going to run this

203
00:10:36,890 --> 00:10:39,400
again so we can see what's happening.

204
00:10:39,395 --> 00:10:41,935
So we run the game

205
00:10:41,930 --> 00:10:46,180
and we can see that we have right now the title screen.

206
00:10:46,175 --> 00:10:47,935
So what is going on in here?

207
00:10:47,930 --> 00:10:50,390
First of all, let's talk about the substring.

208
00:10:50,389 --> 00:10:52,819
Let me just show you what that is.

209
00:10:52,820 --> 00:10:54,680
Okay, so in here you can see

210
00:10:54,680 --> 00:10:57,080
the string dot substring method and

211
00:10:57,080 --> 00:11:00,500
definition and retrieves a substring from this instance.

212
00:11:00,500 --> 00:11:03,100
And you can see we can use an int 32,

213
00:11:03,095 --> 00:11:06,455
retrieves a substring, which will obviously a string.

214
00:11:06,455 --> 00:11:08,185
Then we have a substring.

215
00:11:08,180 --> 00:11:11,570
Substring starts at a specific character position

216
00:11:11,570 --> 00:11:13,910
and continues to the end of that string.

217
00:11:13,910 --> 00:11:16,040
So this is what's happening in here.

218
00:11:16,040 --> 00:11:18,340
We are getting the last index

219
00:11:18,335 --> 00:11:21,365
where we have this forward slash.

220
00:11:21,365 --> 00:11:23,915
And then we are using a substring of that.

221
00:11:23,915 --> 00:11:26,945
So remember how previously that would be displayed.

222
00:11:26,945 --> 00:11:29,485
I'm going to print out

223
00:11:29,480 --> 00:11:32,890
the scene path in here

224
00:11:32,885 --> 00:11:34,885
again so you can clearly

225
00:11:34,880 --> 00:11:36,740
see how the all of that is working.

226
00:11:36,740 --> 00:11:38,600
Well, I'm taking my time to explain

227
00:11:38,600 --> 00:11:40,990
everything because this is a bit confusing.

228
00:11:40,985 --> 00:11:43,955
So on the console there we go, Assets, scenes,

229
00:11:43,955 --> 00:11:45,835
and the last index where we have

230
00:11:45,830 --> 00:11:48,890
this forward slash and then a title screen.

231
00:11:48,890 --> 00:11:51,050
We have the last index,

232
00:11:51,050 --> 00:11:53,000
which is the integer right here.

233
00:11:53,000 --> 00:11:55,420
And then the name is a substring which

234
00:11:55,415 --> 00:11:59,035
starts at the last slash plus one.

235
00:11:59,030 --> 00:12:01,190
So we start immediately after

236
00:12:01,190 --> 00:12:04,900
the visit right here after the last slash.

237
00:12:04,895 --> 00:12:07,915
Now the final step is to remove also the dot.

238
00:12:07,910 --> 00:12:09,440
So I'm going to do that.

239
00:12:09,440 --> 00:12:13,720
And in here I'm going to say that int dot

240
00:12:13,715 --> 00:12:19,835
is equal to name dot last index of.

241
00:12:19,835 --> 00:12:24,095
And then I'm going to use the little dot.

242
00:12:24,095 --> 00:12:27,145
And then finally I'm going to print out.

243
00:12:27,140 --> 00:12:29,240
And probably you should do

244
00:12:29,240 --> 00:12:31,160
this now that you know how everything is done.

245
00:12:31,160 --> 00:12:33,910
Name dot substring.

246
00:12:33,905 --> 00:12:38,725
And where is it between 0 and the dot.

247
00:12:38,720 --> 00:12:42,080
And this is also another form of the substring.

248
00:12:42,080 --> 00:12:43,460
You can see it right here,

249
00:12:43,460 --> 00:12:46,040
a substring and 32 and 32.

250
00:12:46,040 --> 00:12:47,810
So when we give it two parameters,

251
00:12:47,810 --> 00:12:51,410
it retrieves a substring from this instance starts at

252
00:12:51,410 --> 00:12:53,450
a specified character position and

253
00:12:53,450 --> 00:12:55,990
has a specified length.

254
00:12:55,985 --> 00:12:58,055
I'm going to go back in here.

255
00:12:58,055 --> 00:12:59,635
I'm going to save all of

256
00:12:59,630 --> 00:13:02,240
that and I'm going to run the game.

257
00:13:02,240 --> 00:13:04,940
And they now run the game.

258
00:13:04,940 --> 00:13:07,970
And you'll see in the console that we have,

259
00:13:07,970 --> 00:13:10,180
first of all, we had the whole path,

260
00:13:10,175 --> 00:13:11,485
then we reduced it.

261
00:13:11,480 --> 00:13:15,200
And finally we have access to the title screen.

262
00:13:15,200 --> 00:13:16,460
So as you can see,

263
00:13:16,460 --> 00:13:20,480
this is very powerful and I will admit a bit complicated,

264
00:13:20,480 --> 00:13:23,130
but this is the only way to actually do it for

265
00:13:23,130 --> 00:13:24,650
actually the only way that I know

266
00:13:24,650 --> 00:13:26,290
maybe there is another way,

267
00:13:26,285 --> 00:13:29,705
but for now, it's time for a challenge.

268
00:13:29,705 --> 00:13:31,375
And your challenge is to set

269
00:13:31,370 --> 00:13:34,100
the text in a new script so make

270
00:13:34,100 --> 00:13:36,560
the text appear and disappear if the player

271
00:13:36,560 --> 00:13:39,470
is in a certain area next to the door,

272
00:13:39,470 --> 00:13:42,800
get a new script and attach it to the UI object.

273
00:13:42,800 --> 00:13:45,740
So obviously, you'll need to create a new script added

274
00:13:45,740 --> 00:13:49,120
to the UI elements or UI canvas,

275
00:13:49,115 --> 00:13:51,005
or maybe even the door if you want,

276
00:13:51,005 --> 00:13:53,885
immediately added to the door,

277
00:13:53,885 --> 00:13:56,065
use the entrepreneur enter and

278
00:13:56,060 --> 00:13:58,730
exit similar to the shop items,

279
00:13:58,730 --> 00:14:02,300
use the E key to open the doors and make

280
00:14:02,300 --> 00:14:06,080
sure we can't see the canvas when we start the game.

281
00:14:06,080 --> 00:14:08,380
So that information, pause the video right

282
00:14:08,375 --> 00:14:12,035
now and go do VJ alone.

283
00:14:12,040 --> 00:14:14,480
Okay, welcome back.

284
00:14:14,480 --> 00:14:17,090
So this video is getting too long.

285
00:14:17,090 --> 00:14:21,050
We are already about over 15 minutes into it,

286
00:14:21,050 --> 00:14:23,900
and I don't want to make this a huge video,

287
00:14:23,900 --> 00:14:25,780
so I'm going to cut it right now.

288
00:14:25,775 --> 00:14:27,125
I hope you did the challenge.

289
00:14:27,125 --> 00:14:30,175
In the next video, we will continue on with everything.

290
00:14:30,170 --> 00:14:32,290
I hope you enjoy it. I'll see you in the next one.

291
00:14:32,285 --> 00:14:35,125
Don't for the first time ever don't commit

292
00:14:35,120 --> 00:14:36,560
your changes because we will

293
00:14:36,560 --> 00:14:38,810
be doing a lot of things and the next one.

294
00:14:38,810 --> 00:14:41,010
So see you then.

