Version: 2022.3
LanguageEnglish
  • C#
Method group is Obsolete

PrefabUtility.CreatePrefab

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete Use SaveAsPrefabAsset instead.

Declaration

public static GameObject CreatePrefab(string path, GameObject go);
Obsolete Use SaveAsPrefabAsset or SaveAsPrefabAssetAndConnect instead.

Declaration

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

Parameters

path The path where the Prefab is saved.
go The GameObject that you want to create a Prefab from.

Returns

GameObject A reference to the created Prefab.

Description

Creates a Prefab from a game object hierarchy.

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