# SetDirty(Object)

> Marks target object as dirty.

## Definition

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

```csharp
public static void SetDirty(Object target)
```

### Parameters

**** (\[Object]\(/engine/6000.7/script-reference/unityengine/object)): The object to mark as dirty.

### Remarks

You can use [EditorUtility.SetDirty](/engine/6000.7/script-reference/unityeditor/editorutility/setdirty.md) when you want to modify an object without creating an undo entry, but still ensure the change is registered and not lost. If the object is part of a Scene, the Scene is marked dirty. If the object may be part of a Prefab instance, you additionally need to call [PrefabUtility.RecordPrefabInstancePropertyModifications](/engine/6000.7/script-reference/unityeditor/prefabutility/recordprefabinstancepropertymodifications.md) to ensure a Prefab override is created.

If you do want to support undo, you should not call [EditorUtility.SetDirty](/engine/6000.7/script-reference/unityeditor/editorutility/setdirty.md) but rather use [Undo.RecordObject](/engine/6000.7/script-reference/unityeditor/undo/recordobject.md) prior to making changes to an object, since this will both mark the object as dirty (or the object's Scene if it is part of a Scene) and provide an undo entry in the editor. You should still also call [PrefabUtility.RecordPrefabInstancePropertyModifications](/engine/6000.7/script-reference/unityeditor/prefabutility/recordprefabinstancepropertymodifications.md) if the object may be part of a Prefab instance.

In the case of [ScriptableObject](/engine/6000.7/script-reference/unityengine/scriptableobject.md), call both [EditorUtility.SetDirty](/engine/6000.7/script-reference/unityeditor/editorutility/setdirty.md) and [Undo.RecordObject](/engine/6000.7/script-reference/unityeditor/undo/recordobject.md), if you want to register the change and support undo.

When you create editor UI for manipulating an object, such as a custom editor to modify serialized properties on a component or asset, if possible, you should use the [SerializedProperty](/engine/6000.7/script-reference/unityeditor/serializedproperty.md) system using [SerializedObject.FindProperty](/engine/6000.7/script-reference/unityeditor/serializedobject/findproperty.md), [SerializedObject.Update](/engine/6000.7/script-reference/unityeditor/serializedobject/update.md), [EditorGUILayout.PropertyField](/engine/6000.7/script-reference/unityeditor/editorguilayout/propertyfield.md), and [SerializedObject.ApplyModifiedProperties](/engine/6000.7/script-reference/unityeditor/serializedobject/applymodifiedproperties.md). This will automatically mark the object as dirty, create an undo entry, and ensure Prefab overrides are created if relevant.

Additional Resources: [EditorUtility.GetDirtyCount](/engine/6000.7/script-reference/unityeditor/editorutility/getdirtycount.md), [EditorUtility.IsDirty](/engine/6000.7/script-reference/unityeditor/editorutility/isdirty.md).
