C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Unity ComponentsUnity is a component-based system. Unity components are functional pieces of every GameObject. If you don't understand the relationship between components and GameObjects, first read the GameObjects page before going any further. To give functionality to a GameObject, you attach different components to it. Even your scripts are components. So we can say, components are isolated functionality that can be attached to an object to give that functionality to that particular object. That means, when an object requires a specific type of functionality, you add the relevant component. A GameObject is like a container for many different components. By default, all GameObject automatically have a Transform component. This is because the Transform defines where the GameObject is located and how it is rotated and scaled. Without a Transform component, the GameObject would not have a location in the world. Creating a GameObjectLet's create an empty GameObject:
Here we can see that even empty GameObject have a Transform Component. Adding ComponentsWe can add the components to the selected GameObject by the Components menu. Let's try to add a Rigidbody to the empty GameObject we just created. To do that, follow the following steps:
This browser lets you navigate the components by category and also has a search box that you can use to locate components by name. We can attach any number or combination of components to a single GameObject. One another important feature of Components is flexibility. When we add a component to a GameObject, there are different values of Properties in the component that can be adjusted in the editor while building a game, or by scripts when running the game.
Next TopicUnity Interface
|