The GameObject is the most important thing in the Unity Editor. Every object in your game is a GameObject. This means that everything thinks of to be in your game has to be a GameObject. However, a GameObject can't do anything on its own; you have to give it properties before it can become a character, an environment, or a special effect.
A GameObject is a container; we have to add pieces to the GameObject container to make it into a character, a tree, a light, a sound, or whatever else you would like it to be. Each piece is called a component.
Depending on what kind of object you wish to create, you add different combinations of components to a GameObject. You can compare a GameObject with an empty pan and components with different ingredients that make up your recipe of gameplay. Unity has many different in-built component types, and you can also make your own components using the Unity Scripting API.
Three important points to remember:
Creating and Destroying GameObjects
Some games handle a number of objects in the scene, but we can also create and remove the treasures, characters, and other objects during gameplay.
In Unity, we can create a GameObject using the Instantiate function, which makes a new copy of an existing object:
Unity can also provide a Destroy function that is used to destroy an object after the frame update has finished or optionally after a short time delay:
Note that the Destroy function is also used to destroy individual components without affecting the GameObject itself. A common mistake is to write something like: