1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:02,000
This video are going to be very short.

3
00:00:02,000 --> 00:00:06,000
I'm going to show you how to make simple input for your mobile phone.

4
00:00:06,000 --> 00:00:08,000
It's going to be simple touch input.

5
00:00:08,000 --> 00:00:12,000
So what we need to do first is go to player and make these two functions public.

6
00:00:12,000 --> 00:00:16,000
Slide button should be public and jump button should be public.

7
00:00:18,000 --> 00:00:20,000
Now let's save it and go back to Unity.

8
00:00:20,000 --> 00:00:21,000
What are you going to do next?

9
00:00:21,000 --> 00:00:25,000
Is go to in-game UI, click UI button, text.

10
00:00:25,000 --> 00:00:27,000
MASH Pro is going to be jump.

11
00:00:31,000 --> 00:00:32,000
Jump button.

12
00:00:34,000 --> 00:00:35,000
We need to make it bigger.

13
00:00:35,000 --> 00:00:36,000
Much bigger.

14
00:00:36,000 --> 00:00:37,000
Like half of the screen.

15
00:00:39,000 --> 00:00:41,000
And we can align it to the right.

16
00:00:41,000 --> 00:00:48,000
So let's click over here, hold alt and shift, click the right side and then maybe put it a bit lower.

17
00:00:50,000 --> 00:00:51,000
And let's duplicate this.

18
00:00:53,000 --> 00:00:53,000
Name it.

19
00:00:53,000 --> 00:00:54,000
Slide.

20
00:00:56,000 --> 00:00:58,000
Button and align it to the left.

21
00:00:59,000 --> 00:01:00,000
A bit lower.

22
00:01:00,000 --> 00:01:01,000
All right.

23
00:01:01,000 --> 00:01:04,000
Now we can select them both and make them transparent.

24
00:01:04,000 --> 00:01:08,000
And when you make a final build, it should be completely transparent like this.

25
00:01:08,000 --> 00:01:12,000
But for now, as we are testing, I'm going to make it slightly visible.

26
00:01:12,000 --> 00:01:13,000
I want to make sure it's working.

27
00:01:13,000 --> 00:01:16,000
Now let's open them and delete text from the inside.

28
00:01:17,000 --> 00:01:18,000
These two we don't need.

29
00:01:20,000 --> 00:01:26,000
Now, next step would be to create a C-sharp script UI jump button.

30
00:01:28,000 --> 00:01:32,000
But let's make it UI button jump.

31
00:01:39,000 --> 00:01:45,000
First, what we need is to go above and type using you to engine event system.

32
00:01:46,000 --> 00:01:49,000
And next, what we're going to use is an interface.

33
00:01:51,000 --> 00:01:54,000
It's a bit difficult to understand, especially if you're a beginner.

34
00:01:55,000 --> 00:01:58,000
But in general, I'll try to explain what the interface does.

35
00:01:58,000 --> 00:02:04,000
So basically interface allows you to have one function with a different functionality on different game

36
00:02:04,000 --> 00:02:08,000
objects that are independent from each other.

37
00:02:08,000 --> 00:02:16,000
For example, we can use a pointer down handler which allows you to call function when a pointer and

38
00:02:16,000 --> 00:02:21,000
pointer is an input device, for example mouse or touch from your finger.

39
00:02:21,000 --> 00:02:28,000
So when pointer on this game object with this interface function will be called let's click alt, enter

40
00:02:28,000 --> 00:02:31,000
and find implement interface the first one.

41
00:02:33,000 --> 00:02:35,000
And this was the function I was talking about.

42
00:02:35,000 --> 00:02:39,000
So we can call this interface from here or from another object.

43
00:02:39,000 --> 00:02:42,000
It's going to be same function with different functionalities.

44
00:02:44,000 --> 00:02:51,000
So for the button jump, we're going to do game manager instance player John Button.

45
00:02:52,000 --> 00:02:54,000
Now let's go back to Unity and create another script.

46
00:02:55,000 --> 00:02:57,000
C-sharp UI.

47
00:02:59,000 --> 00:03:03,000
But on slide and I'm using name button, slide and button jump.

48
00:03:03,000 --> 00:03:06,000
So they are next to each other in the asset folder.

49
00:03:06,000 --> 00:03:12,000
Otherwise, with the names like John Button and Slide button, slide button would be here and John Button

50
00:03:12,000 --> 00:03:15,000
would be at the top because of the alphabetic order.

51
00:03:15,000 --> 00:03:16,000
Yeah.

52
00:03:16,000 --> 00:03:19,000
So let's go to what was that button slide.

53
00:03:19,000 --> 00:03:21,000
We're going to delete, start an update.

54
00:03:21,000 --> 00:03:24,000
You're going to type here using Unity Engine.

55
00:03:27,000 --> 00:03:28,000
U.N. systems.

56
00:03:28,000 --> 00:03:30,000
And then over here, comma.

57
00:03:31,000 --> 00:03:32,000
Boynton down.

58
00:03:32,000 --> 00:03:35,000
We need to find a pointer down.

59
00:03:35,000 --> 00:03:37,000
Click all to enter implement interface.

60
00:03:39,000 --> 00:03:42,000
And here it's going to be the manager, for instance.

61
00:03:44,000 --> 00:03:45,000
Player.

62
00:03:45,000 --> 00:03:46,000
Slide button.

63
00:03:47,000 --> 00:03:49,000
And we actually can do this.

64
00:03:53,000 --> 00:03:55,000
And then click this icon over here to clean it up.

65
00:03:56,000 --> 00:03:57,000
That's the same for button jump.

66
00:04:01,000 --> 00:04:04,000
By the way, there is no difference to do it this way or that way.

67
00:04:04,000 --> 00:04:07,000
I mean, curly brackets or this one, just this one looks.

68
00:04:07,000 --> 00:04:08,000
I like how it looks.

69
00:04:08,000 --> 00:04:08,000
That's it.

70
00:04:10,000 --> 00:04:16,000
We have these two functions now, as I said, on pointer down will be called when pointer down on the

71
00:04:16,000 --> 00:04:19,000
object with this script.

72
00:04:19,000 --> 00:04:26,000
So we need to find our jump button, drag it here, then we need to find slide button, drag it here.

73
00:04:27,000 --> 00:04:28,000
Let's go and see this.

74
00:04:28,000 --> 00:04:32,000
Now tap to start to buttons appeared and jump is working.

75
00:04:34,000 --> 00:04:37,000
So when Jump is working and Slide is working.

76
00:04:37,000 --> 00:04:38,000
Now let's do a bit of polish on this.

77
00:04:38,000 --> 00:04:42,000
Let's take our info bar and find extra live display.

78
00:04:44,000 --> 00:04:47,000
I want to duplicate this and move it to the left like this.

79
00:04:49,000 --> 00:04:50,000
I want to delete one.

80
00:04:50,000 --> 00:04:54,000
And instead of heart over here, I want to place spread of the slide.

81
00:04:54,000 --> 00:04:56,000
Let's go to graphics player.

82
00:04:57,000 --> 00:04:58,000
Slide.

83
00:04:58,000 --> 00:05:00,000
You can take one of the sprites.

84
00:05:01,000 --> 00:05:03,000
Place it here and we need to rename the object.

85
00:05:04,000 --> 00:05:05,000
Slide icon.

86
00:05:05,000 --> 00:05:06,000
We can make it bigger.

87
00:05:06,000 --> 00:05:12,000
Let's press t and if you hold shift, you can increase the size without messing up the resolution.

88
00:05:12,000 --> 00:05:15,000
So maybe something like this is okay.

89
00:05:20,000 --> 00:05:26,000
And this is, I guess, just approximate size, something that you think looks okay.

90
00:05:26,000 --> 00:05:27,000
Don't sweat it out too much.

91
00:05:27,000 --> 00:05:31,000
Now, let's change this one to slide display.

92
00:05:33,000 --> 00:05:37,000
And I want to open my in-game UI here.

93
00:05:37,000 --> 00:05:40,000
I want to add new image that's going to be slide icon.

94
00:05:40,000 --> 00:05:42,000
So slide icon.

95
00:05:42,000 --> 00:05:48,000
Then let's go to our player script over here and we're going to make this slide call down counter public.

96
00:05:48,000 --> 00:05:51,000
Let's go above, find it, make it public.

97
00:05:51,000 --> 00:05:53,000
But I want to hide it in the inspector.

98
00:05:53,000 --> 00:05:54,000
So public.

99
00:05:55,000 --> 00:05:57,000
Hide, Inspector.

100
00:05:58,000 --> 00:05:59,000
Yeah.

101
00:05:59,000 --> 00:06:06,000
And back in the game UI in the update info function we're going to do slide icon enabled equals to layer.

102
00:06:06,000 --> 00:06:10,000
What was that slide cool down counter less than zero.

103
00:06:10,000 --> 00:06:15,000
If you remember, we use very same statement when we try to do slide it to make sure it's available

104
00:06:16,000 --> 00:06:18,000
right here in the slide button.

105
00:06:21,000 --> 00:06:24,000
And we have here a slide button slide called down counter less than zero.

106
00:06:24,000 --> 00:06:31,000
So basically we making this icon enabled if we can do a slide and now back in unity, we need to assign

107
00:06:31,000 --> 00:06:32,000
the image.

108
00:06:34,000 --> 00:06:39,000
Let's drag it here and now, whenever you try to do slide, if it's not available, picture is not going

109
00:06:39,000 --> 00:06:40,000
to be there.

110
00:06:43,000 --> 00:06:44,000
Slide.

111
00:06:45,000 --> 00:06:46,000
Okay, good.

112
00:06:46,000 --> 00:06:47,000
Let's go to the next video.

