Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CreatePrefab

Creates a Prefab from a game object hierarchy.
Read time 1 minuteLast updated 6 days ago

Definition

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

CreatePrefab(string, GameObject)

Creates a Prefab from a game object hierarchy.
Warning
Deprecated. Use SaveAsPrefabAsset instead.
public static GameObject CreatePrefab(string path, GameObject go)

Parameters

path

The path where the Prefab is saved.

The GameObject that you want to create a Prefab from.

Returns

Type

Description

GameObjectA 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.
public static GameObject CreatePrefab(string path, GameObject go, ReplacePrefabOptions options)

Parameters

path

The path where the Prefab is saved.

The GameObject that you want to create a Prefab from.

Returns

Type

Description

GameObjectA 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.