OnEnteringEditModeAttribute
Marks a static method as a callback to be invoked when the Editor enters 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 OnEnteringEditModeAttribute : LifecycleAttributeBase
Remarks
Methods marked with this attribute are called when entering Edit mode. This happens:
- After exiting Play mode in the Editor.
- After code reload in Edit mode.
Use this callback to:
- Initialize Editor-specific systems and UI.
- Restore Edit mode state.
- Set up Edit mode data structures.
This is a method attribute that can only be applied to methods with no parameters and return type .
staticvoidAdditional Resources: OnExitingEditModeAttribute, OnEnteringPlayModeAttribute, AfterManagedObjectsRestoredAttribute.
Examples
using UnityEditor.Scripting.LifecycleManagement;using UnityEngine;public static partial class EditorModeManager{ [OnEnteringEditMode] static void OnEditModeEntered() { Debug.Log("Entered Edit mode"); }}
Constructors
Constructor | Description |
|---|---|
| OnEnteringEditModeAttribute() | Marks the decorated static method to be invoked when entering Edit mode. |