In this lecture, we'll explore Unity's component system. The big idea is that we can affect the state and behavior of our GameObjects by either attaching components to or removing components from those GameObjects. We've actually already done this. C# scripts are components in Unity's component system. When we attach the print message script to the main camera, which is a GameObject in our scene, we were affecting the behavior of that main camera, that GameObject in the scene. Let's go to Unity and take a closer look at this. This is our game from last time. When I opened this up, it didn't actually open Scene0, it opened a new untitled scene with only a main camera in it. Of course, that's alarming. You say, "Whoa, what happened to all the GameObjects that I added to the scene and all that stuff?" If Unity opens up, and often it opens up on the scene you were previously working on, but sometimes it doesn't. If it opens up with an untitled scene with just the main camera, come over here to your Scenes folder, and double-click the scene you were working on, and everything should be fine. I know that's a little scary when that happens, you think you've lost all your work. But it's happened to me a number of times over the last few months, so just don't panic, go ahead and open up the scene you were working on. If I select the Main Camera in the hierarchy window, over here in the Inspector, I see the component that have been attached by default to the Main Camera. We have a Transform component that we can use to change the position rotation, and scale of the GameObject that's selected. I won't do that on the camera, I'll do that on the teddy bear in just a moment. You'll notice by the way, that the camera is at z negative 10. The camera is not in the z equals 0 plane, which is where we're going to put all our GameObjects in our 2D games, the camera is toward us, 10 World units. We've already looked at changing the size of the camera. We changed it from five to three to get our teddy bear to appear larger in the screen than it was before. There are lots of other characteristics that you could change in the camera component. You could change Orthographic to Perspective but don't do that. We want an orthographic camera in our 2D games. We also have an Audio Listener, which we'll learn more about when we add sound effects to our game, which is not in this course, it's later in the courses in the specialization. If I select the TeddyBear in the hierarchy view, we'll see the TeddyBear has two components by default. It has a Transform component, and pretty much every GameObject we add to the scene is going to have a Transform component because that GameObject needs to have this state in the game world. It has a position, where is it located in the game world? It has a rotation and 0, 0, 0 means not rotated at all, and it has a scale, which we talked about when we did the sprites and GameObjects lecture last time. We're going to leave our scale as 1, 1, 1 here in this particular game. As I suggested, for the art assets you create, you should create sprites that you don't have to scale to be the correct size in your game. We also have a sprite renderer, because we have a sprite that's getting drawn for this particular GameObject. You may have noticed that the camera doesn't have a sprite renderer component. And that's because, of course, the camera doesn't get drawn in the scene. The camera is actually used to draw the scene. I'm going to zoom back out so we can see the impact of the changes I'm going to make on the actual game view. So I can change the scale of this teddy bear by changing x from one to five, for example. As you see down below, I now have a very wide teddy bear. I can make my teddy bear tall as well. But changing z for my teddy bear has no impact at all because we're using an orthographic camera and because we're just constrained to the x-y plane for our 2D game, so we'll just change Z back to one. Of course I can change the location too, I can move the teddy bear to five and x. I can move the teddy bear to three and y and just partially outside the scene. The big idea is we can change the state of the teddy bear by changing position, rotation, or scale in our transform component. We can also change the behavior of our teddy bear and any of our GameObjects by attaching other components to the teddy bear. Once we start talking about physics, we'll see that we can attach components that make the teddy bear have physics behaviors. We've already seen that we can attach scripts as components, like when we attach the script to the main camera to make the main camera print a message. We can modify the behavior of our GameObjects as well by attaching components to or detaching components from that GameObject. I will say sometimes you attach a component and you just want to deactivate it for awhile. There's a checkbox next to each component, not the transform component. You can't turn off the transform component to tell the game engine, no, you don't get to know where this GameObject is. But for the sprite renderer, for example, I can deactivate it by clicking this checkbox and then the sprite renderer on those GameObject is in active. The GameObject is still there and it's still at 000. But by turning off the sprite renderer, I've deactivated this component. I'll activate it again because we would in fact like to see our teddy bear. But if you've added a component that you just don't want to be active right now, like a script for example, that you don't want to be active right now, you can just uncheck the component so you don't have to remove it and then add it later again. You can just uncheck it to deactivate it. To recap. In this lecture, we talked about the fact that we can use Unity's component system to affect the state and behavior of our GameObjects. Based on the components we have attached to those GameObjects.