# CreatePrimitive(PrimitiveType)

> Creates a GameObject primitive with Undo support. The created primitive will have any existing Preset applied to it, see Preset Manager.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public static GameObject CreatePrimitive(PrimitiveType type)
```

### Parameters

**** (\[PrimitiveType]\(/engine/6000.7/script-reference/unityengine/primitivetype)): The type of primitive to create.

### Returns

| Type                                                                    | Description |
| ----------------------------------------------------------------------- | ----------- |
| [GameObject](/engine/6000.7/script-reference/unityengine/gameobject.md) |             |

### Examples

```csharp
using UnityEngine;
using UnityEditor;

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