1
00:00:00,000 --> 00:00:04,490
Welcome back, My favorite game developers in this video,

2
00:00:04,485 --> 00:00:06,515
instead of every single time having

3
00:00:06,510 --> 00:00:08,580
to look either in the console for

4
00:00:08,580 --> 00:00:11,040
the debug or to look on the object

5
00:00:11,040 --> 00:00:13,850
of the game manager to know how much coins we have.

6
00:00:13,845 --> 00:00:16,415
We've actually created the UI canvas

7
00:00:16,410 --> 00:00:19,020
to register all of the Bitcoins that we have.

8
00:00:19,020 --> 00:00:21,360
So as you can see, we have 0 right now,

9
00:00:21,360 --> 00:00:24,360
but if we pick up a coin, we get that.

10
00:00:24,360 --> 00:00:26,670
So let's not waste any more time and let's

11
00:00:26,670 --> 00:00:29,780
get started in this really simple video.

12
00:00:29,775 --> 00:00:34,415
Oh, okay, So now it's time to actually display

13
00:00:34,410 --> 00:00:38,790
the Bitcoins that we've picked up on our UI canvas.

14
00:00:38,790 --> 00:00:42,270
So I'm going to make the scene a bit bigger.

15
00:00:42,265 --> 00:00:45,565
I'm going to find the Canvas and here somewhere.

16
00:00:45,560 --> 00:00:47,650
So double-click on the UI canvas.

17
00:00:47,645 --> 00:00:48,925
Let's open it up.

18
00:00:48,920 --> 00:00:50,540
Let's see what we have

19
00:00:50,540 --> 00:00:54,730
and click on View UI canvas so we can see everything.

20
00:00:54,725 --> 00:00:56,935
We have the weapon UI health,

21
00:00:56,930 --> 00:01:01,430
and let's go ahead and create a new empty game up.

22
00:01:01,430 --> 00:01:04,340
No, not, sorry, not on the health on

23
00:01:04,340 --> 00:01:07,580
the UI canvas create an empty game object.

24
00:01:07,580 --> 00:01:15,530
And this will be the coins or whatever.

25
00:01:15,530 --> 00:01:18,110
But coin tracker, I don't know,

26
00:01:18,110 --> 00:01:21,340
with corn occur. There we go.

27
00:01:21,335 --> 00:01:23,695
So Bitcoin tracker, and here we are going

28
00:01:23,690 --> 00:01:26,150
to add in the UI and image,

29
00:01:26,150 --> 00:01:28,010
and this will represent the image,

30
00:01:28,010 --> 00:01:31,400
the image. There we go.

31
00:01:31,400 --> 00:01:33,350
And it's just going to be,

32
00:01:33,350 --> 00:01:36,580
let me look through the sprites.

33
00:01:36,575 --> 00:01:40,175
Sprites make these smaller.

34
00:01:40,175 --> 00:01:42,085
There we go, the coins,

35
00:01:42,080 --> 00:01:46,270
whereas the coin I just saw it, coins, star coins.

36
00:01:46,265 --> 00:01:50,855
And let's add the image therapy goals at the sprite.

37
00:01:50,855 --> 00:01:52,925
We can set to native size.

38
00:01:52,925 --> 00:01:54,775
There we go. I think it's good enough.

39
00:01:54,770 --> 00:01:56,650
We put it right here

40
00:01:56,645 --> 00:01:59,905
just next to you can put it wherever you want obviously,

41
00:01:59,900 --> 00:02:01,120
as I always say,

42
00:02:01,115 --> 00:02:03,385
but I'm just going to set it right here.

43
00:02:03,380 --> 00:02:05,000
And then I'm going to create a,

44
00:02:05,000 --> 00:02:06,740
another UI in here.

45
00:02:06,740 --> 00:02:08,750
Oh, so sorry for that.

46
00:02:08,750 --> 00:02:11,240
We should not have put the image.

47
00:02:11,240 --> 00:02:13,730
Let me just set the image.

48
00:02:13,730 --> 00:02:17,150
Position bug will move the entire object in just a bit.

49
00:02:17,150 --> 00:02:20,930
And I'm going to create text much pro in here.

50
00:02:20,930 --> 00:02:23,840
And obviously I'm going to make it,

51
00:02:23,840 --> 00:02:27,100
let's say 99, 99, bold,

52
00:02:27,095 --> 00:02:29,545
and change the font on it,

53
00:02:29,540 --> 00:02:33,010
make it the one with the robot thinking,

54
00:02:33,005 --> 00:02:35,635
I'll move this whole object here.

55
00:02:35,630 --> 00:02:39,770
I'm move the image a bit to the left.

56
00:02:39,770 --> 00:02:40,460
There we go.

57
00:02:40,460 --> 00:02:43,990
And then the text a bit to the right.

58
00:02:43,985 --> 00:02:50,345
And this will be the amount of BDC text.

59
00:02:50,345 --> 00:02:53,645
And we'll keep it at my 99 just to represent everything.

60
00:02:53,645 --> 00:02:56,825
And we'll set it in the middle on the alignment

61
00:02:56,825 --> 00:03:00,485
and set it to auto size, increased the maximum.

62
00:03:00,485 --> 00:03:04,265
And let me change the text a bit. There we go.

63
00:03:04,265 --> 00:03:06,115
That looks good. I think.

64
00:03:06,110 --> 00:03:08,660
Yeah, that looks good in my opinion.

65
00:03:08,660 --> 00:03:10,280
So we have the number right here

66
00:03:10,280 --> 00:03:13,060
displayed above the health and every time we pick up,

67
00:03:13,055 --> 00:03:14,285
we should get this.

68
00:03:14,285 --> 00:03:16,895
Okay, great, So I'm going to save this.

69
00:03:16,895 --> 00:03:19,615
I'm going to go into the UI canvas

70
00:03:19,610 --> 00:03:22,250
and I'm going to open up the UI Manager.

71
00:03:22,250 --> 00:03:25,070
So in here, obviously we'll need a reference.

72
00:03:25,070 --> 00:03:27,020
So the first reference is going to be

73
00:03:27,020 --> 00:03:31,190
a serialized field of the type text.

74
00:03:31,190 --> 00:03:33,610
What was it text Mesh Procore,

75
00:03:33,605 --> 00:03:37,265
taxed mash Pro GUI.

76
00:03:37,265 --> 00:03:38,185
You I agree.

77
00:03:38,180 --> 00:03:39,350
Okay, that's it.

78
00:03:39,350 --> 00:03:46,340
And the BTC text.

79
00:03:46,340 --> 00:03:47,840
Save that.

80
00:03:47,840 --> 00:03:49,490
Okay, so let's go back in here.

81
00:03:49,490 --> 00:03:54,970
Let's get a reference to this day. Now.

82
00:03:54,965 --> 00:03:56,225
There we go.

83
00:03:56,225 --> 00:03:58,355
And let's apply the changes

84
00:03:58,355 --> 00:04:00,545
on the UI canvas so it's applied everywhere.

85
00:04:00,545 --> 00:04:01,435
Okay, great.

86
00:04:01,430 --> 00:04:03,290
Now back in our end here,

87
00:04:03,290 --> 00:04:05,030
what are we going to do?

88
00:04:05,030 --> 00:04:07,190
Well, obviously every single time

89
00:04:07,190 --> 00:04:09,730
we pick up a coin or we start again,

90
00:04:09,725 --> 00:04:11,935
or we spend the point,

91
00:04:11,930 --> 00:04:15,530
we want it to be displayed right here on the UI canvas.

92
00:04:15,530 --> 00:04:18,440
And this is going to be your challenge to set

93
00:04:18,440 --> 00:04:21,910
the value of the coin and updated every single time.

94
00:04:21,905 --> 00:04:23,995
So create a method that updates

95
00:04:23,990 --> 00:04:26,500
the coin text and the UI Manager,

96
00:04:26,495 --> 00:04:29,315
set it at the beginning so we will not

97
00:04:29,315 --> 00:04:31,955
need to know where is the beginning, where do we sell it?

98
00:04:31,955 --> 00:04:35,735
And also make sure that every time we add or remove

99
00:04:35,735 --> 00:04:39,625
coins to update it in the UI canvas.

100
00:04:39,620 --> 00:04:41,200
So that out of the way,

101
00:04:41,195 --> 00:04:46,465
pause the video right now and go do the Chaldean.

102
00:04:46,460 --> 00:04:48,620
Okay, welcome back.

103
00:04:48,620 --> 00:04:52,160
So in the UI Manager,

104
00:04:52,160 --> 00:04:53,840
whereas the UI Manager,

105
00:04:53,840 --> 00:04:56,390
and let's scroll down and in here let's

106
00:04:56,390 --> 00:04:59,200
create a public void,

107
00:04:59,195 --> 00:05:06,355
Update Bitcoin text.

108
00:05:06,350 --> 00:05:09,680
And in here all I'm going to do is access

109
00:05:09,680 --> 00:05:14,290
the PTC text, text, text.

110
00:05:14,285 --> 00:05:18,385
And it's going to be equal to the integer right here,

111
00:05:18,380 --> 00:05:23,080
which is the amount of BDC.

112
00:05:23,075 --> 00:05:27,335
And it's going to be equal to amount of BTC. There we go.

113
00:05:27,335 --> 00:05:30,025
So this does not work because you

114
00:05:30,020 --> 00:05:32,840
cannot convert into string.

115
00:05:32,840 --> 00:05:36,290
So I'm going to add the dot two string.

116
00:05:36,290 --> 00:05:37,810
Save that.

117
00:05:37,805 --> 00:05:39,535
So this is a bit of a trick.

118
00:05:39,530 --> 00:05:41,170
Maybe you didn't know how to do that.

119
00:05:41,165 --> 00:05:42,925
There are other ways around this,

120
00:05:42,920 --> 00:05:46,430
but this is one way that I'm going to show you for now.

121
00:05:46,430 --> 00:05:48,610
So back in the game manager,

122
00:05:48,605 --> 00:05:50,375
as soon as we start.

123
00:05:50,375 --> 00:05:52,645
So in start or you know what?

124
00:05:52,640 --> 00:05:54,010
As long as we have the awake,

125
00:05:54,005 --> 00:05:55,165
let's sell it in the awake.

126
00:05:55,160 --> 00:05:58,730
But the problem with the awake is that it

127
00:05:58,730 --> 00:06:03,850
might start before we have an instance of the UI Manager.

128
00:06:03,845 --> 00:06:08,015
So for that, let's just do it and start for now.

129
00:06:08,015 --> 00:06:09,785
It's a bit safer.

130
00:06:09,785 --> 00:06:12,475
Ui Manager, dot instance,

131
00:06:12,470 --> 00:06:15,910
dot update, Bitcoin texts,

132
00:06:15,905 --> 00:06:18,935
and it's going to be the current Bitcoins.

133
00:06:18,935 --> 00:06:21,025
And then when we get the Bitcoins,

134
00:06:21,020 --> 00:06:24,950
we are also going to update this

135
00:06:24,950 --> 00:06:27,440
and the spent after

136
00:06:27,440 --> 00:06:30,290
we sell it because we don't want to have negative,

137
00:06:30,290 --> 00:06:32,080
so we're not going to sell it in here.

138
00:06:32,075 --> 00:06:34,225
We said it after we check if we have

139
00:06:34,220 --> 00:06:36,980
less than 0 and then we make it 0.

140
00:06:36,980 --> 00:06:38,320
So save that.

141
00:06:38,315 --> 00:06:40,435
Back in our game.

142
00:06:40,430 --> 00:06:43,970
We are going to run the game.

143
00:06:43,970 --> 00:06:46,030
Let's make this a bit bigger.

144
00:06:46,025 --> 00:06:48,445
So run the game, we should see 0 in

145
00:06:48,440 --> 00:06:50,900
here because we don't have any coins.

146
00:06:50,900 --> 00:06:52,040
There we go. We have 0.

147
00:06:52,040 --> 00:06:53,660
And now when we pick this up,

148
00:06:53,660 --> 00:06:55,190
so please mute audio.

149
00:06:55,190 --> 00:06:58,250
When we pick this up, we should see that we get ten.

150
00:06:58,250 --> 00:07:01,030
Excellent. So now we can pick up

151
00:07:01,025 --> 00:07:04,235
our coins and we of course also can spend them.

152
00:07:04,235 --> 00:07:06,175
We don't have the opportunity to spend them,

153
00:07:06,170 --> 00:07:08,600
but in a bit we will start creating

154
00:07:08,600 --> 00:07:11,410
shops and that's when we will be able to spend them.

155
00:07:11,405 --> 00:07:13,415
So with that out of the way,

156
00:07:13,415 --> 00:07:14,755
I'm not sure why I keep saying

157
00:07:14,750 --> 00:07:18,290
this mixture to commit all of your changes.

158
00:07:18,290 --> 00:07:20,420
I hope you are enjoying and I'll see you in

159
00:07:20,420 --> 00:07:22,670
the next video where we will learn

160
00:07:22,670 --> 00:07:24,400
how we can actually earn

161
00:07:24,395 --> 00:07:27,205
our bitcoins and not just pick them up off the floor.

162
00:07:27,200 --> 00:07:29,520
So see you then.

