Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


OnEnteringEditModeAttribute

Marks a static method as a callback to be invoked when the Editor enters Edit mode.
Read time 4 minutesLast updated 5 days ago

Definition

[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
static
methods with no parameters and return type
void
.
Additional 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.

Inheritance

Inherited Members