# SaveAssetIfDirty

> Writes all unsaved changes to the specified asset to disk.

## Definition

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

## SaveAssetIfDirty(GUID)

Writes all unsaved changes to the specified asset to disk.

```csharp
public static void SaveAssetIfDirty(GUID guid)
```

### Parameters

**** (GUID): The GUID of the asset to be saved, if dirty.

### Remarks

This function is similar to [AssetDatabase.SaveAssets](/engine/6000.0/script-reference/unityeditor/assetdatabase/saveassets.md), and likewise should not be called during serialization.

It does not invoke [AssetModificationProcessor.OnWillSaveAssets(string\[\])](/engine/6000.0/script-reference/unityeditor/assetmodificationprocessor/onwillsaveassets.md), as the asset is directly specified.

## SaveAssetIfDirty(Object)

Writes all unsaved changes to the specified asset to disk.

```csharp
public static void SaveAssetIfDirty(Object obj)
```

### Parameters

**** (\[Object]\(/engine/6000.0/script-reference/unityengine/object)): The asset object to be saved, if dirty.

### Remarks

This function is similar to [AssetDatabase.SaveAssets](/engine/6000.0/script-reference/unityeditor/assetdatabase/saveassets.md), and likewise should not be called during serialization.

It does not invoke [AssetModificationProcessor.OnWillSaveAssets(string\[\])](/engine/6000.0/script-reference/unityeditor/assetmodificationprocessor/onwillsaveassets.md), as the asset is directly specified.
