ドキュメント

Unity Engine

Unity Engine

CreateGameObject

Creates a new GameObject.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

CreateGameObject(Scene, HideFlags, string, Type[])

Creates a new GameObject.
public static GameObject CreateGameObject(Scene scene, HideFlags hideFlags, string name, params Type[] types)

Parameters

scene

Scene where the GameObject should be created.

hideFlags

HideFlags to assign to the GameObject.

name

Name of the GameObject.

types

The optional types to add to the GameObject when created.

Returns

Type

Description

GameObjectReturns 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

name

Name of the GameObject.

types

The optional types to add to the GameObject when created.

Returns

Type

Description

GameObjectReturns 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)); }}