CreateGameObject
Creates a new GameObject.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor
CreateGameObject(Scene, HideFlags, string, Type[])
Creates a new GameObject.
public static GameObject CreateGameObject(Scene scene, HideFlags hideFlags, string name, params Type[] types)
Parameters
Returns
Type | Description |
|---|---|
| GameObject | Returns the GameObject that was created. |
Examples
using UnityEngine;using UnityEditor;public class CreateComponentExample{ [MenuItem("ObjectFactoryExample/Create Camera GameObject")] public void CreateCameraEditor() { Selection.activeGameObject = ObjectFactory.CreateGameObject("Camera", typeof(Camera)); }}
CreateGameObject(string, Type[])
Creates a new GameObject.
public static GameObject CreateGameObject(string name, params Type[] types)
Parameters
Returns
Type | Description |
|---|---|
| GameObject | Returns the GameObject that was created. |
Examples
using UnityEngine;using UnityEditor;public class CreateComponentExample{ [MenuItem("ObjectFactoryExample/Create Camera GameObject")] public void CreateCameraEditor() { Selection.activeGameObject = ObjectFactory.CreateGameObject("Camera", typeof(Camera)); }}