Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SavePrefabAsset

Saves the version of an existing Prefab Asset that exists in memory back to disk.
Read time 1 minuteLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor

SavePrefabAsset(GameObject)

Saves the version of an existing Prefab Asset that exists in memory back to disk.
public static GameObject SavePrefabAsset(GameObject asset)

Parameters

Any GameObject that is part of the Prefab Asset to save.

Returns

Type

Description

GameObjectThe root GameObject of the saved Prefab Asset.

Remarks

The GameObject must be part of an existing prefab asset. If you pass a GameObject from an instance of a prefab asset in a scene, Unity automatically finds and saves the corresponding prefab asset instead.

SavePrefabAsset(GameObject, bool)

Saves the version of an existing Prefab Asset that exists in memory back to disk.
public static GameObject SavePrefabAsset(GameObject asset, out bool savedSuccessfully)

Parameters

Any GameObject that is part of the Prefab Asset to save.

savedSuccessfully

The result of the save action, either successful or unsuccessful. Use this together with the console log to get more insight into the save process.

Returns

Type

Description

GameObjectThe root GameObject of the saved Prefab Asset.

Remarks

The GameObject must be part of an existing prefab asset. If you pass a GameObject from an instance of a prefab asset in a scene, Unity automatically finds and saves the corresponding prefab asset instead.