# OnExitingEditModeAttribute

> Marks a static method as a callback to be invoked when the Editor exits Edit mode.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor.Scripting.LifecycleManagement](/engine/6000.5/script-reference/unityeditor/scripting/lifecyclemanagement.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class OnExitingEditModeAttribute : LifecycleAttributeBase
```

## Remarks

Methods marked with this attribute are called when exiting Edit mode. This happens:

* Before entering Play mode in the Editor.
* Before code reload in Edit mode.

Use this callback to:

* Save Edit mode state.
* Clean up Editor-specific resources.
* Prepare for Play mode or code reload.

This is a method attribute that can only be applied to `static` methods with no parameters and return type `void`.

Additional Resources: [OnEnteringEditModeAttribute](/engine/6000.5/script-reference/unityeditor/scripting/lifecyclemanagement/onenteringeditmodeattribute.md), [OnExitingPlayModeAttribute](/engine/6000.5/script-reference/unityengine/onexitingplaymodeattribute.md), BeforeManagedObjectsBackupAttribute

## Examples

```csharp
using UnityEditor.Scripting.LifecycleManagement;
using UnityEngine;

public static partial class EditorModeManager
{
    [OnExitingEditMode]
    static void OnEditModeExited()
    {
        Debug.Log("Exiting Edit mode");
    }
}
```

## Constructors

| Constructor                                                                                                                                  | Description                                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [OnExitingEditModeAttribute()](/engine/6000.5/script-reference/unityeditor/scripting/lifecyclemanagement/onexitingeditmodeattribute/ctor.md) | Marks the decorated static method to be invoked when exiting Edit mode. |
