OnExitingEditModeAttribute
Marks a static method as a callback to be invoked when the Editor exits Edit mode.
Read time 4 minutesLast updated 6 days ago
Definition
- Type: Class
- Namespace: UnityEditor.Scripting.LifecycleManagement
- Assembly: UnityEditor.CoreModule
- Inherits from: LifecycleAttributeBase
[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 methods with no parameters and return type .
staticvoidAdditional Resources: OnEnteringEditModeAttribute, OnExitingPlayModeAttribute, BeforeManagedObjectsBackupAttribute
Examples
using UnityEditor.Scripting.LifecycleManagement;using UnityEngine;public static partial class EditorModeManager{ [OnExitingEditMode] static void OnEditModeExited() { Debug.Log("Exiting Edit mode"); }}
Constructors
Constructor | Description |
|---|---|
| OnExitingEditModeAttribute() | Marks the decorated static method to be invoked when exiting Edit mode. |