public static GameObject CreatePrimitive (PrimitiveType type);

参数

type要创建的原始项的类型。

描述

创建一个游戏对象原始项。

using UnityEngine;
using UnityEditor;

public class CreatePrimitiveExample { [MenuItem("ObjectFactoryExample/Create Cube GameObject")] public void CreateCubeEditor() { Selection.activeGameObject = ObjectFactory.CreatePrimitive(PrimitiveType.Cube); } }