 So now let's actually load up Unity for the first time. And we're gonna create a new project. Here's just showing projects I've already created, just tutorial projects I've gone through. And I'm gonna create something called example. You can specify if it's gonna be a 3D project or a 2D project, understand that in Unity there's really not much distinction between 3D and 2D. 2D is just a special case of 3D where our camera is an orthographic projection. It's a projection without any perspective distortion. And a few other settings are different when you start a 2D project. But if I start a 3D project and want to switch over to making a 2D, it's just a couple of settings I have to change anyway. So you can just, it doesn't really matter here at the start whether you make it 3D or 2D, it's not a huge deal. We though are going to be starting with 3D. So we'll make a 3D project and Unity will load up here, takes a little time. There we go. Okay. So the first basic concept to understand about Unity is that your project contains some number of assets. What are assets? Well, they're just the data elements that are used in your game and they come in various different kinds. There's sound assets, image assets, mesh assets, that's 3D geometry. Those kinds that I just mentioned, those are things that you create externally to Unity. You use other programs, images of course you would create in a program like Photoshop or Illustrator or whatever. And sounds of course are various different programs for creating sounds and music. And 3D models, meshes, those are things you create in programs like Maya and Blender. It's probably the one you wanna start with if you're gonna get into 3D modeling. It's a whole very complicated thing unto itself. So we're not gonna talk about that at all. We're going to, for a long time, we're just gonna be sticking with very, very basic built-in meshes of cubes and spheres and cylinders and really basic stuff like that. Again, we're not gonna focus on making things look good at all. We wanna learn as much about Unity itself, not really about creating good art, which is a whole field unto itself. Anyway, so a lot of kinds of assets you'll create external and you wanna bring them in and let's see. I'll just, what do I have? I have this duck. I'm gonna drag that into Unity here. Make an asset out of that. And now what's happened is in my project here, I can open up and explore my project. And here's my project folder. And in your project folder, you have these five subfolders. Assets is where all your assets go and there's the image file I just brought in. And it now has an associated Metafile. Unity will generate these Metafiles for every asset you bring in. And what that Metafile is, we can actually just open that up in a text editor. And what it looks like is, well, one thing here is that for every asset you bring in, Unity wants to have an associated ID, a unique ID for that, a GUID for it. So just randomly generate this thing here and then it has other information about the file. And this is describing how the asset's gonna get imported if we go back to Unity and click on the asset. You have all these options. It depends on what kind of asset we're talking about in this case as an image. So there's various different ways like you would want to have the image compressed when it's brought into your project and stuff like that. So that's all described in the Metafile. And be sure not to delete the Metafiles. You wanna keep them around, make sure they have the same name and stay in sync with these files. So I mean, we could, it's up to us exactly how we structure stuff in our asset folder. We can just create random, we'll just call images and I'm gonna move these into there and just be sure to bring, move them together. And as long as you do that, you need to be fine with it. No, actually I'm not sure, maybe that will break some things because now the path to that asset has changed. I think what you really wanna do, let me go back actually, let me undo the move. Oh, notice that the directors themselves have made a files. Yeah, actually I think the thing to do you really wanna do is to make sure that what's gonna happen in your project is things in your game will reference your assets and you don't want those references to break when the file path changes. So if you move something from one directory to another or change its name, you don't wanna have those references break. That's what the GUIDs are about. So instead, if you wanna rename things or move them, you should do so inside Unity. So now if I rename this to Mallard for Mallard 2, we go look at the directory. The metafile, its name has been updated in sync so it's no longer mallard2.jpg, it's mallard with node number two. If I were to move this into images here in Unity also, it's moving the metafile along with it. And I don't know if anything, I don't think anything in here changes, but yeah. Anyway, just to be safe, you should really only move and rename stuff in your assets directory, but that'll prevent the references to assets from breaking. So an image is an example of an asset that will be importing in from an external program, but then there are some assets that you'll be creating directly inside Unity. For example, there's what's called a material. I'll just leave this with a default name, new material and the inspector here, I select the asset here and it shows all the options about the material. What is a material? Well, a mesh, as I described, is it's the wireframe of a 3D object. It's just the vertices in three-dimensional space and the edges that connect them. It's not the actual texture information about how the polygons get filled in. That's what a material describes. A material is all the information about what should be drawn on the surfaces and how they should be drawn. So we can specify textures. We can join, this is called albedo. That's the main texture you see on an image. So here, let's just set that up. I can drag this here. And okay, so now this is a material which is referencing the texture such that when you apply this material to a mesh, that texture will be drawn on the surfaces. And how the coordinates of the texture match up with the geometry, the various polygons that make up the mesh. That's something you generally arrange and match up in 3D modeling packages like Blender as I mentioned. So there's a lot of complications to that which we won't go into as of yet, if ever. But anyway, so we can also just apply on the material. We can say everything here is red. So it's just gonna tint material to being red. You have controls over things like that. You have controls over how lights are supposed to affect these surfaces. Lots of options and we have various rendering modes which again, all these details we won't get into as of yet. But that's the idea of a material. It's a little strange because you might assume naively that, oh, well I have my meshes and I wanna apply textures to them so I just associate the texture with the mesh. But no, we create these materials, apply the materials to the meshes and the material describes what the surfaces should look like and there's a lot of options about how exactly we want the surfaces to get rendered. So again, a material is a kind of asset we create inside Unity. There are many other kinds which we'll get to in time. One for example, C-sharp script. So this just creates a file called .cs and if I double click this, it'll open up the code in Visual Studio. You can configure that in Unity if you wanna use other text editors. Understand that, yes, Visual Studio has a C-sharp compiler and when I edit my code and save, it'll compile my code or attempt to compile my code and here's the compilation error and it'll tell me there's a problem but Unity has its own variant of the mono C-sharp.net runtime so what you compile in Visual Studio is not the compiled code being used in here so it's actually in a sense that it'll just be compiled twice when we save here. Regardless, it's nice to have Visual Studio just a good environment for writing C-sharp code and Visual Studio these days is practically free. For a long time, Unity by default would install mono develop on your system but very recently they've moved over to now Visual Studio is installed by default and associated with Unity. So this is the default choice going forward. So we'll come back to how to write your code later but anyway, so this is a kind of asset. It's a file that sits in your assets folder. It has an associated meta file and it's something that certain elements in our game can make reference to as we'll see. That's most everything we need to know about assets for now, we'll talk more about them later and that's everything under the project window. The project window really probably should just be called the assets window but they call it the project window and then up here what's called the hierarchy window that's showing us all the game objects in our current scene. And by the way, if you don't have Unity looking like this and you want it to look like this this is what I recommend. Come up to layouts, select two by three it'll arrange things like this but you can just drag this down, dock it there that's what I prefer. And I like to have the console open so I like to dock that down here. That's my preference. That's what I find generally most useful but this is all customizable and it's up to you. Here it's showing my current scene that's what this untitled thing is and the entitled currently has two game objects in it one called main camera, one called directional light. Those are just the default objects included in a new scene and if I hit control S right now what I'm gonna be saving is an asset called a scene a dot unity file and I'm just gonna call this example because that's the name of my project could call it whatever I want but now you'll see an assets in my root folder there's an example scene and we actually can view that in a text editor it's just a YAML file which is sort of an alternative to like JSON or XML and it's just all the information in text form describing the scene and all of the game objects currently in it which right now is just those two game objects so there's actually not that much in it as of yet most typical games will have much more complicated scenes anyway just understand that's really just a text file that's how it gets saved and what are these game objects? Well a game object is just a logical container for what are called components this main camera here if I click on it oops the inspector's stuck it's still showing me the new material because earlier I locked that I'm gonna unlock it so now whatever I click on whether an assets or a game object is gonna show me the components of that object in the inspector so click on the main camera and it's a game object containing this transform component which I can expand and collapse this camera component I'm expanding and collapse and then a flare layer and an audio listener so right now it's just four components and you can see the list of all the component types under here there's many different kinds there's things for lights, for physics for particle effects, meshes, rendering stuff just a whole bunch of stuff which you'll learn in time so in this particular case the transform component that's the one component that every single game object is gonna have if I right click here and create a new empty game object it'll have by default name game object but I can rename it to whatever I want I'll call it Fred and Fred by default this new game object just has a transform component every game object has to have a transform component whether it's gonna use it or not it's a little strange the transform is the position in 3D space it's a rotation in space and a scale those nine coordinates together are the transform of an object and everything has to have it whether it's gonna be used or not the directional light for example a directional light is a kind of light that casts on the scene as if from a very distant large source of light like the sun and all the rays of light shine down in parallel and because of that because it's logically a light that's in effect infinitely far away it doesn't matter where you position the light but it is casting rays in parallel that's what it's kind of showing you with the icon when I select my directional light it's showing these yellow beams and I can rotate the object and that is relevant that part of the transform actually affects the lighting of the scene but if I translate it around if I move it up and down left and right that has no bearing so it doesn't matter where we position this thing but it doesn't matter how we rotate it so there are cases like that where the transform may be ignored in this entirety or maybe only some aspects of the transform are relevant but again all game objects have to have a transform component a camera component as you might assume makes a game object into a camera it's something from which we can render the world and there's nothing in our world yet except skybox at the moment this will be a lot clearer once we add visible objects into the scene but here I'm moving the camera around I can rotate it up and down and this is relevant for the camera because where you position the camera of course affects what you see relative to the objects in the scene and the flare layer that component simply adds a flare effect to your camera so depending upon what lights it's looking at there are cases where you'll see a little flare I don't know why they put that on there by default and audio listener that's a component which picks up sound coming from audio source components so other objects you're gonna attach audio source components to and from those audio sources we can play sound assets and based on proximity an audio listener component which by default is attached to our camera is gonna pick that up and generally you wanna hear stuff from the perspective of the user's view so that's why it's generally attached to the camera Fred, we have this empty game object let me move the directional light out of the way it's right up in our faces okay so Fred you can always just double click on an object to center the scene view on it this is the scene view this is where we move stuff around and you have this preview grid of things whereas the game object this is what the game looks like from the current camera which is by default this main camera the only camera we have at the moment anyway so Fred, we can add components to it let's make a visible mesh and to make a mesh we can actually see we need two components we need what's called a mesh filter and we need a mesh renderer the mesh filter is where we just specify what the mesh is and we don't have any mesh assets yet in our project but there are these built in meshes cube, capsule, cylinder, plane, sphere, and quad we'll just make a cube and right now our cube is rendering as just pink that's Unity's way of making sure that a mesh stands out if it doesn't have an associated material you wanna catch those mistakes so that you can fix them so that's why it's bright pink or magenta I guess you would say so we can apply the material to it and we have a material here, our duck material which I've shaded red let's get rid of that red tint so it looks like a duck and we wanna just associate that onto the mesh renderer component of Fred and we can just do so by dragging here or I could have done the same thing I think by dragging to Fred I think that also would work or if you look at the components and the materials in some cases a mesh actually might have multiple materials applied to it this is an array component that's why it expands and collapses like this and you can specify a size so we can have like three and then we can apply three materials I don't think it would actually do anything if we applied three different materials because the way the mesh is its geometry is defined there's only one material it's expecting so I think the other two would be ignored anyway let's just set that back to one so it has one material and this is where we can also apply the material we can come here, select from materials here like there's this default diffuse material let's just make something white but let's go back to the duck and we can directly drag from assets to here so that's another way of applying the material to the mesh just be clear here we have two components on our Fred game object the mesh filter which specifies the mesh mesh renderer which specifies various options about how lighting should affect the mesh we'll just go with the defaults for now and also it's where we specify what materials are being rendered on the mesh so why are these separate components you may be asking why not just have one component which is both the renderer and the filter well there are actually cases where maybe you don't necessarily want to have a mesh be rendered you don't want to have it visible but you want to use its geometry to define like say a collision box or something like that so you might have a mesh filter without a mesh renderer I don't think it ever makes sense to a mesh renderer without a mesh filter I don't know I think you might even get an error if you delete this let me see what happens remove component and I'm gonna try and play the scene is it gonna accept that well we don't get any errors but we definitely don't get anything rendered so let's just undo that put the mesh filter back okay and now if we render the scene okay then you see there it is this is actually the game being played and it looks just the same as when we didn't play but that's just because we have a totally static game that doesn't do anything as of yet it's just rendering from the camera and nothing else is happening let's move that camera around so we can see it in action and move it closer to our duck move it down something like that that's good enough whatever okay so that's a basic example of a game object again a game object is really just a logical container for some number of components and it's the components that really define what kind of game object that is there's some cases where a component you can only have one instance on a particular game object like I don't think you can give a game object multiple mesh renderers I believe let me try that yeah we got an error message if we try and add a second mesh renderer to this object because it already has one there are cases where if you have one kind of component you can't have a different kind of component like I think under tile map can I add a tile map renderer no yeah because we have a mesh renderer you can't also have a tile map renderer that just doesn't make sense there's a conflict there are certain cases where if you add a component other components are also required and generally if you try and add one of those components it'll automatically add any other required components so there are some various rules like that it just depends on what kind of components we're talking about but there are cases where you can add seemingly unrelated components to the same game object because maybe you just want them to logically be grouped together or you want them to share the same transform that's one reason to group otherwise unrelated components onto the same game object sometimes that's useful but again game object just sort of a generic container and we can call them whatever we want that's totally arbitrary in fact I can very quickly duplicate my object here in hierarchy if I just hit control D and by default it'll give it the same name but with a number after it to distinguish but actually I can give two or more objects the same name and that doesn't necessarily harm anything though in our code as you see it as a way of finding objects by name and if you have multiple objects with the same name it's indeterminate which one you retrieve so generally you probably want to give things unique names but you don't have to I'll just get rid of the second Fred there we go now for our purposes we're probably gonna be creating a lot of simple game objects like this so rather than having to create an empty game object and then add the relevant components so we can see like a cube or a sphere as a convenience under game object here we can just simply come 3D object and there's a cube and it automatically adds in the cube mesh filter and a mesh render using the default material at the start so it just looks white but we can quickly change that with whatever material we want I'm gonna undo that and keep it white it also adds this box collider we'll talk much more about colliders later but understand for now that what a game object looks like doesn't necessarily correspond to how it collides with other things by default the objects that you render don't collide with anything else at all they'll just pass right through and render on top of each other if you want to detect when things collide that's where colliders come in and then we'll talk about that when we talk about physics so we're not gonna do anything with collisions at the moment so I'm just gonna actually remove this component but it's actually kind of harmless right now so it doesn't really matter let me also get a sphere in here okay I don't want to move that over actually what I'm gonna do is I'm gonna reset this component, I'm gonna reset it and it just has the default values so it's gonna reset back to the origin you can, if I modify the stuff, the rotation the position you can reset the position rotation independently I'm just gonna reset the whole thing so it's back at the origin as we see down there and we'll do the same for the cube so they'll be overlapping each other just reset the whole thing center on that in the view by double clicking and let's make the sphere bigger so that it pokes out so we can see it poking out of the cube there we go okay and to make that stand out clear I'm gonna create another material where, well I could just use the duct material and apply that to the sphere okay now you can see what's going on I think and if we just pan down here you can see it's like poking out through this cube anyway so you can just see there's two distinct objects there oh and one small thing I wanna make clear here in the inspector view it's showing us all the components of this object and it sort of visually implies that material here is a component but it's not a component it's an asset and it's being referenced by the mesh renderer but as a convenience the inspector is showing you all the materials being referenced by the components of this object it's just a convenience so you can come down here and look at the materials being applied to this object and perhaps mess with these values if you so choose but this is really just an asset being referenced by one of the components