Unity - Scripting API: GameObject.GameObject
GameObject Constructor
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Declaration
public GameObject();
Declaration
public GameObject(string name);
Declaration
public GameObject(string name, params Type[] components);
Parameters
| Parameter | Description |
|---|---|
| name | The name of the GameObject, specified as a string. The name is stored in the name property of the GameObject. |
| components | The components to attach, specified as an array of types that inherit from Component. |
Description
Creates a new GameObject, with optional parameters to specify a name and set of components to attach.
Use the constructor with no arguments to create a GameObject with an empty name property and only a Transform component attached.
Use the constructor with name parameter to create a GameObject with the specified value as the name property and only a Transform component attached.
Use the constructor with name and components parameters to create a GameObject with the specified name and the specified components attached, in addition to the Transform component.