TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Unity Components

Unity Components with Introduction, Installing, GameObject, First Unity Project, Unity 2D, Sprite Unity, Loops, If Statement, Data Types, Swith Statements, Unity UI, Unity Asset Store etc.

<< Back to UNITY

Unity Components

Unity 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 GameObject

Let's create an empty GameObject:

  • From the menu bar click on GameObject -> Create Empty
Unity Components
  • Select the new GameObject, and look at the inspector from the top left corner of the window.
Unity Components

Here we can see that even empty GameObject have a Transform Component.

Unity Components

Adding Components

We 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:

  • Select the GameObject and from the menu bar choose Component -> Physics -> Rigidbody.
Unity Components
  • When you do this, you will get the Rigidbody's properties appear in the inspector.
Unity Components
  • Another option is to use the Component Browser to open this Component Browser press 'Add Component' button.
Unity Components

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




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf