GameObject
Manual     Reference     Scripting   
Reference Manual > Components > The GameObject > GameObject

このドキュメントは有志により翻訳されたもので、オフィシャルではありません。オリジナルのページはこちら
This document is unofficially translated by users.Please see the original document here.

翻訳に関する修正など、ご連絡はこちらまで。
Please send e-mail to here, when you have any question about the translation.

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.

Hints