# CreatePrefab

> Creates a Prefab from a game object hierarchy.

## Definition

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

## CreatePrefab(string, GameObject)

Creates a Prefab from a game object hierarchy.

> **Warning:**
>
> **Deprecated.** Use SaveAsPrefabAsset instead.

```csharp
public static GameObject CreatePrefab(string path, GameObject go)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The path where the Prefab is saved.**** (\[GameObject]\(/engine/6000.6/script-reference/unityengine/gameobject)): The GameObject that you want to create a Prefab from.

### Returns

| Type                                                                    | Description                        |
| ----------------------------------------------------------------------- | ---------------------------------- |
| [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) | A reference to the created Prefab. |

### Remarks

Use this to create a Prefab from a GameObject in the hierarchy, and give it a path to save the Prefab in.

## CreatePrefab(string, GameObject, ReplacePrefabOptions)

Creates a Prefab from a game object hierarchy.

> **Warning:**
>
> **Deprecated.** Use SaveAsPrefabAsset or SaveAsPrefabAssetAndConnect instead.

```csharp
public static GameObject CreatePrefab(string path, GameObject go, ReplacePrefabOptions options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The path where the Prefab is saved.**** (\[GameObject]\(/engine/6000.6/script-reference/unityengine/gameobject)): The GameObject that you want to create a Prefab from.**** (\[ReplacePrefabOptions]\(/engine/6000.6/script-reference/unityeditor/replaceprefaboptions)):&#x20;

### Returns

| Type                                                                    | Description                        |
| ----------------------------------------------------------------------- | ---------------------------------- |
| [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) | A reference to the created Prefab. |

### Remarks

Use this to create a Prefab from a GameObject in the hierarchy, and give it a path to save the Prefab in.
