Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

OnExitingPlayModeAttribute

class in UnityEngine

/

Inherits from:Unity.Scripting.LifecycleManagement.LifecycleAttributeBase

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Marks a static method as a callback to be invoked when exiting Play mode.

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

  • When stopping Play mode in the Editor.
  • Before code reload in Play mode (Editor only).
  • Before application quit (Player only).

Use this callback to:

  • Save Play mode state.
  • Clean up runtime resources.
  • Prepare for Edit 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: OnEnteringPlayModeAttribute, BeforeManagedObjectsBackupAttribute.

using UnityEngine;

public static partial class PlayModeManager { [OnExitingPlayMode] static void OnPlayModeExited() { Debug.Log("Exiting Play mode"); } }

Constructors

Constructor Description
OnExitingPlayModeAttributeMarks the decorated static method to be invoked when exiting Play mode.

Inherited Members