1 00:00:04,120 --> 00:00:05,140 ‫Welcome back. 2 00:00:05,170 --> 00:00:13,420 ‫In this video, I would like to talk about a very, very important concept in unity and also about keeping 3 00:00:13,420 --> 00:00:18,310 ‫your project clean, because so far, we have simply created things. 4 00:00:18,310 --> 00:00:24,160 ‫For example, we have created some assets, we have created game objects, but we haven't kept our assets 5 00:00:24,160 --> 00:00:25,750 ‫folder, for example, tidy. 6 00:00:26,110 --> 00:00:31,420 ‫And also we haven't used something very important which is called prefabs yet. 7 00:00:31,420 --> 00:00:35,740 ‫And I would like to talk about those things and show you how to use them correctly. 8 00:00:35,860 --> 00:00:43,330 ‫So one thing is that we should have folders for the different types of assets that we're using. 9 00:00:43,330 --> 00:00:49,510 ‫For example, one folder would be scripts and in there we should have all of our scripts. 10 00:00:49,510 --> 00:00:56,620 ‫So for example, our player movement and our trigger script and whenever we create new scripts, we 11 00:00:56,620 --> 00:00:58,870 ‫should also put them into your scripts folder. 12 00:00:59,290 --> 00:01:04,000 ‫Then we have another one called Materials and we could even create two different ones. 13 00:01:04,000 --> 00:01:09,670 ‫We could create a material, one for simple materials and then one for physics materials. 14 00:01:09,670 --> 00:01:17,560 ‫But I'm just going to use the same folder for both and I'm going to drag my materials in there. 15 00:01:18,070 --> 00:01:24,760 ‫You can keep your scene or your scenes outside of any folder, or you could also create a scenes folder. 16 00:01:24,790 --> 00:01:30,790 ‫I personally prefer to have my scenes in my assets route folder, but of course you could go ahead and 17 00:01:30,790 --> 00:01:32,770 ‫create an additional folder for that. 18 00:01:33,550 --> 00:01:39,370 ‫Now, the next one that I would like to talk to you about is simply saving your scene. 19 00:01:39,370 --> 00:01:46,240 ‫So it's really important to save your scene before you close your project because scenes are not automatically 20 00:01:46,240 --> 00:01:47,830 ‫saved when you close your project. 21 00:01:47,830 --> 00:01:53,500 ‫And that could lead to you losing all of your game objects that you have within your hierarchy. 22 00:01:53,890 --> 00:01:56,680 ‫So objects are all of those pieces here. 23 00:01:56,680 --> 00:01:58,540 ‫Every single one of them is an object. 24 00:01:58,540 --> 00:02:00,460 ‫The main camera is in game object. 25 00:02:00,460 --> 00:02:05,170 ‫The direct channel light is in game object, the player is a game object and so forth. 26 00:02:05,170 --> 00:02:13,090 ‫And if we create a new object, we can simply create an empty object which doesn't contain any information 27 00:02:13,090 --> 00:02:17,740 ‫except for I hope you know which thing is always there for every single object. 28 00:02:18,190 --> 00:02:19,090 ‫It's the. 29 00:02:21,410 --> 00:02:23,270 ‫Transform component. 30 00:02:23,300 --> 00:02:26,330 ‫So every single object, even an empty one. 31 00:02:26,720 --> 00:02:29,870 ‫So let's create a new game object which is empty. 32 00:02:29,900 --> 00:02:32,450 ‫It still has a transform component. 33 00:02:33,230 --> 00:02:33,500 ‫All right. 34 00:02:33,500 --> 00:02:36,230 ‫So you can create game objects this way. 35 00:02:36,230 --> 00:02:39,860 ‫So 2D objects, 3D objects and so forth. 36 00:02:40,280 --> 00:02:43,850 ‫And those objects, they are within your scene. 37 00:02:44,150 --> 00:02:49,250 ‫So whenever you, for example, close your scene, those objects are not available anymore. 38 00:02:49,280 --> 00:02:55,610 ‫And if you want to make them available for, for example, other scenes or in general want to reproduce 39 00:02:55,610 --> 00:03:00,980 ‫them programmatically, what you can do is you can create prefabs out of them. 40 00:03:01,280 --> 00:03:08,510 ‫So let's say we want to have this cube that we have created here as a prefab that we can re-use any 41 00:03:08,510 --> 00:03:09,140 ‫time. 42 00:03:09,140 --> 00:03:14,960 ‫What we can do is we can drag that cube into our assets. 43 00:03:15,290 --> 00:03:22,850 ‫And as you can see, it will be a cube dot prefab, so it will be a prefabricated, which we then can 44 00:03:22,850 --> 00:03:24,500 ‫re-use any time. 45 00:03:24,590 --> 00:03:28,910 ‫So now if I delete all of my cubes from here, let's delete them. 46 00:03:30,140 --> 00:03:33,920 ‫I can drag a new cube into my game any time. 47 00:03:34,430 --> 00:03:36,200 ‫So let's drag that in here. 48 00:03:36,590 --> 00:03:43,340 ‫Let's reposition it a little bit, and now I can drag another one in here and so forth. 49 00:03:43,340 --> 00:03:51,530 ‫So these cubes that I create in here, they are prefabs, and you usually create prefabs out of many 50 00:03:51,530 --> 00:03:58,010 ‫different objects, all of those that you would like to reuse in different scenes or that you would 51 00:03:58,010 --> 00:04:04,220 ‫like to reproduce, for example, programmatically, a very important one which you always should have, 52 00:04:04,250 --> 00:04:07,790 ‫is your player, of course, because maybe you could die. 53 00:04:07,790 --> 00:04:13,910 ‫Or maybe you go into a different scene and you want to have the player with all of its capabilities 54 00:04:13,910 --> 00:04:15,530 ‫in the different scene as well. 55 00:04:15,530 --> 00:04:17,240 ‫So let's say a different level. 56 00:04:17,330 --> 00:04:20,390 ‫You want to have the same player in level two, three and four. 57 00:04:20,660 --> 00:04:26,870 ‫So it's really important to have it as a prefab so you can reuse it in a different scene. 58 00:04:28,490 --> 00:04:38,060 ‫So now that we have this prefab and this cube prefab, let's create a new folder, create folder and 59 00:04:38,060 --> 00:04:39,920 ‫call it prefabs. 60 00:04:40,280 --> 00:04:43,100 ‫And now let's drag all of our prefabs in there. 61 00:04:45,140 --> 00:04:47,030 ‫All right, so that's really important. 62 00:04:47,030 --> 00:04:55,580 ‫Prefabs are a very important aspect of game development with unity, and we will use that quite often. 63 00:04:55,760 --> 00:04:56,210 ‫All right. 64 00:04:56,210 --> 00:04:58,280 ‫So that's it for this video. 65 00:04:58,280 --> 00:05:00,140 ‫Now, you know what game objects are. 66 00:05:00,170 --> 00:05:02,930 ‫We have seen them before, but now you know even better. 67 00:05:02,930 --> 00:05:05,330 ‫And then you also know how to use prefabs. 68 00:05:06,320 --> 00:05:06,650 ‫Great. 69 00:05:06,650 --> 00:05:09,680 ‫So in the next video, we will have a look at components. 70 00:05:09,680 --> 00:05:11,060 ‫So see you in the next video.