# SavePrefabAsset

> Saves the version of an existing Prefab Asset that exists in memory back to disk.

## Definition

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

## SavePrefabAsset(GameObject)

Saves the version of an existing Prefab Asset that exists in memory back to disk.

```csharp
public static GameObject SavePrefabAsset(GameObject asset)
```

### Parameters

**** (\[GameObject]\(/engine/6000.0/script-reference/unityengine/gameobject)): Any GameObject that is part of the Prefab Asset to save.

### Returns

| Type                                                                    | Description                                    |
| ----------------------------------------------------------------------- | ---------------------------------------------- |
| [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) | The 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.

Additional Resources: [PrefabUtility.SaveAsPrefabAsset](/engine/6000.0/script-reference/unityeditor/prefabutility/saveasprefabasset.md), [PrefabUtility.GetCorrespondingObjectFromSource](/engine/6000.0/script-reference/unityeditor/prefabutility/getcorrespondingobjectfromsource.md).

## SavePrefabAsset(GameObject, bool)

Saves the version of an existing Prefab Asset that exists in memory back to disk.

```csharp
public static GameObject SavePrefabAsset(GameObject asset, out bool savedSuccessfully)
```

### Parameters

**** (\[GameObject]\(/engine/6000.0/script-reference/unityengine/gameobject)): Any GameObject that is part of the Prefab Asset to save.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): 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                                    |
| ----------------------------------------------------------------------- | ---------------------------------------------- |
| [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) | The 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.

Additional Resources: [PrefabUtility.SaveAsPrefabAsset](/engine/6000.0/script-reference/unityeditor/prefabutility/saveasprefabasset.md), [PrefabUtility.GetCorrespondingObjectFromSource](/engine/6000.0/script-reference/unityeditor/prefabutility/getcorrespondingobjectfromsource.md).
