1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:02,000
In this section, we're going to create interruptible objects.

3
00:00:02,000 --> 00:00:05,000
And actually, believe me or not, we are halfway there.

4
00:00:05,000 --> 00:00:09,000
There are a few things left to do, and basically our game is ready.

5
00:00:09,000 --> 00:00:12,000
Then we just need to make a menu and basically that's it.

6
00:00:12,000 --> 00:00:13,000
It will be ready.

7
00:00:13,000 --> 00:00:14,000
So you're almost there.

8
00:00:14,000 --> 00:00:17,000
Just keep it on and you'll have yourself your own game.

9
00:00:17,000 --> 00:00:19,000
And this video are going to be very short.

10
00:00:19,000 --> 00:00:21,000
We're going to create a game manager.

11
00:00:21,000 --> 00:00:26,000
We need it to use it like a kind of a hub between objects and scripts.

12
00:00:26,000 --> 00:00:32,000
So in this example, we're going to store information about coins, and if we need to store something

13
00:00:32,000 --> 00:00:33,000
else, we can do it in the game.

14
00:00:33,000 --> 00:00:38,000
Manager So first thing we're going to do is to create a C-sharp script and I'm going to name it as game

15
00:00:38,000 --> 00:00:39,000
manager.

16
00:00:39,000 --> 00:00:42,000
And I was going to have this fancy icon, which is really cool.

17
00:00:42,000 --> 00:00:46,000
Now let's go inside of Game Manager and make it work as a single tone.

18
00:00:46,000 --> 00:00:51,000
Single Singleton allows you to access objects from different, different scripts at any time.

19
00:00:51,000 --> 00:00:58,000
Basically, let's do public static game manager instance and you can use any name but common practices

20
00:00:58,000 --> 00:01:00,000
to just type instance.

21
00:01:00,000 --> 00:01:06,000
Now we can delete start an update until we need it and just create an awake function in the wake.

22
00:01:06,000 --> 00:01:09,000
I'm going to type instance equals to this.

23
00:01:09,000 --> 00:01:12,000
Now because we did this because we made it public static.

24
00:01:12,000 --> 00:01:18,000
We can get access to this again from any script and let's go and try to do that while we're here.

25
00:01:18,000 --> 00:01:24,000
I'm going to create a public int that I'm going to name as coins and I'll save it.

26
00:01:24,000 --> 00:01:25,000
Now let's go back.

27
00:01:26,000 --> 00:01:30,000
I'm going to create an empty object then to be named as game manager.

28
00:01:31,000 --> 00:01:33,000
I can reset, transform.

29
00:01:33,000 --> 00:01:35,000
Close it and drag.

30
00:01:35,000 --> 00:01:36,000
Monitor over here.

31
00:01:36,000 --> 00:01:37,000
And not to go far away.

32
00:01:37,000 --> 00:01:39,000
Let's create an empty object.

33
00:01:39,000 --> 00:01:40,000
I'm going to name it as a coin.

34
00:01:41,000 --> 00:01:44,000
Add the new script with the name Coin.

35
00:01:45,000 --> 00:01:49,000
Let's go inside and just add the start function.

36
00:01:49,000 --> 00:01:54,000
I'll do game manager dot instance, dot coins plus plus.

37
00:01:56,000 --> 00:01:56,000
All right.

38
00:01:56,000 --> 00:01:57,000
I'm going to go back to Unity.

39
00:02:01,000 --> 00:02:02,000
That's duplicated twice.

40
00:02:02,000 --> 00:02:05,000
So we have three coins now, one sell enter play mode.

41
00:02:05,000 --> 00:02:08,000
I can see my coins is equal to three.

42
00:02:08,000 --> 00:02:11,000
So this is how you can get access to game manager from any script.

43
00:02:11,000 --> 00:02:16,000
You just do game manager that instance and do some stuff with it.

44
00:02:16,000 --> 00:02:18,000
Now let's go to next video and make a proper coin.

