GameObject

GameObjects are containers for all other Components. All objects in your game are inherently GameObjects.


An empty GameObject

Creating GameObjects

GameObjects do not add any characteristics to the game by themselves. Rather, they are containers that hold Components, which implement actual functionality. For example, a Light is a Component which is attached to a GameObject.

If you want to create a Component from script, you should create and empty GameObject and then add required Component using gameObject.AddComponent(ClassName) function. You can't create Component and then make a reference from object to it.

From scripts, Components can easily communicate with each other through message sending or the GetComponent(TypeName) function. This allows you to write small, reusable scripts that can be attached to multiple GameObjects and reused for different purposes.

Details

Aside from being a container for the components, GameObjects have a Tag, a Layer and a Name.

Tags are used to quickly find objects, utilizing the Tag name. Layers can be used to cast rays, render, or apply lighting to certain groups of objects only. Tags and Layers can be set with the Tag Manager, found in Edit->Project Settings->Tags.

Static Checkbox

In Unity, there is a new checkbox in the GameObject called Static. This checkbox is used for:


The Static checkbox is used when generating Occlusion data

When generating Occlusion data, marking a GameObject as Static will enable it to cull (or disable) mesh objects that cannot be seen behind the Static object. Therefore, any environmental objects that are not going to be moving around in your scene should be marked as Static.

For more information about how Occlusion Culling works in Unity please read the Occlusion Culling page.

Hints

Page last updated: 2010-09-03