Introduction
In this blog, we will learn about the different elements of Unity. Unity consists of a set of elements (or components) that altogether form a Game, these are developed using a unity engine. These elements play a major role in making the game interactive, engaging and vibrant. It adds features that can clearly express the objective of the game and make players enjoy the game.
Elements of Unity
Following are some of the major elements of Unity:
Assets
First in the list of elements of Unity comes an asset. An asset is just a way to represent any item that can be used in the game or project. Some assets may come from a file that is not a part of unity, that is, they are imported and come from outside of unity. For example, an image file, an audio file, any 3D model, or any other type of file supported by unity.
There are certain asset types that can be created within unity and that are- An animator Controller, Animation files, an audio mixer, Pictures, or a Render Texture. We also have an asset market in unity where we can buy and sell our different kinds of assets. Assets of different types can range from environmental to even character assets. All different types of assets create a game scene and are very important for making a project functional and attractive.
Project
Project is yet another component in the list of elements of Unity. A unity project is the collection of files and dictionaries rather than a single unity file. A project file consists of all the associative assets, which may contain the libraries and assets sub-folders also. The project includes all the functionality of the scene. A project can be located on our device locally or over clouds affiliated with unity. It is a very important part of any development cycle cause any minor changes in the project files might crash the whole system.
Packages
Packages are just a bundle of settings that you may need for your project and can be installed along with the editor of unity or, other packages you can install as needed.
Whenever you create a project in unity, the project manager will read the project, manifest and recommend different types of packages according to it. Then unity will send the request to the package registry server. The package registry sends all the data to be downloaded and then they are installed for your project. Each project has its own manifest which lists the packages to be installed.
There are many different types of ways to install packages in your project. For a better understanding, refer to the table below.
TYPE |
STEPS INVOLVED |
Directory |
Step-1: You will have to open the package manager window and select unity registry from the drop-down menu. Step-2: After clicking unity registry, we can select what you want to select from the list of packages. Step-3: After selecting the version you want, you need to click on the install button. |
Local Folder |
Step-1: The project manager can load a package from anywhere in your local drive irrespective of the location in the drive. Step-2: To add a package locally, we have to click the add button from the status bar. Step-3: In the drop-down list, there will be an option of adding a package. After that, we have to select the add package from the disk to bring up the file browser. Step-4: Then select the file you want to install. |
Git URL |
Step-1: In order to load a package from Git URL, we have to select the add button from the status bar and select the package option. Step-2: Then select Add package from the Git URL option and enter/paste the required git URL in the dialogue box. |
Scene
Another component that comes in the list of Elements of Unity is the Scene. Scenes contain all your objects that will be used at that level. Whenever you create a new project, the scene window will contain only basic components (like camera, directional).
The two types of scenes are-
- Saving Scene- To save the scene you are currently working on, Choose file > save the scene from the menu or press ctrl/cmd + S. Scenes are saved in the project assets folder and thus appear in the project window.
- Opening Scene- In order to begin or continue a scene you will have to double click on any asset currently situated in the project window.
If the scene is unsaved you will be prompted to save or discard the changes.
Components
The basic building blocks and functional pieces of any GameObject and their activities are components. By default, every GameObject has been set to Transform component. This will decide where the GameObject will be positioned and transformed within the Unity environment.
GameObject
As the name suggests, GameObject is an object present within the game. They will not provide any additional functionality to the game project, but they are the holders of the components mentioned above.
Prefab
Unity lets you create, change or modify any game object with all its components and properties. Prefabs are nothing but reusable GameObjects. Whenever you have to use the same assets multiple times in any scene or Unity scenario, it is better to convert it to a Prefab rather than just blindly copying and pasting the assets multiple times as prefab automatically syncs all the objects.
All the assets under the same Prefab contain the same properties or values, if you want to change any values in a prefab, you will have an overall effect as all the assets under a prefab in the scene will be changed.
Some common examples of prefab are described in the table below.
PREFAB |
DESCRIPTION |
Projectiles | For example, an archer arches an arrow prefab each time. |
Environmental Assets | For example, trees are shown in a game prefab multiple times around the different places. |
Player’s main Character | For example, a player prefab can be placed at the starting point each time the game restarts. |
Non-player characters | For example, a similar type of enemy may appear multiple times in a game. |
Build
Build is something that is an exported adaption of the game project. It will contain all the essential scenes for playback on any other specific platform.