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

OnEnteringPlayModeAttribute

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 entering Play mode.

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

  • When starting Play mode in the Editor.
  • When starting the Player application.
  • After code reload in Play mode (Editor only).

Use this callback to:

  • Initialize Play mode systems and game state.
  • Set up Play mode data structures.
  • Prepare runtime systems.

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

Additional resources: OnExitingPlayModeAttribute, RuntimeInitializeOnLoadMethodAttribute, AfterManagedObjectsRestoredAttribute.

using UnityEngine;

public static partial class PlayModeManager { [OnEnteringPlayMode] static void OnPlayModeEntered() { Debug.Log("Entered Play mode"); } }

Constructors

Constructor Description
OnEnteringPlayModeAttributeMarks the decorated static method to be invoked when entering Play mode.

Inherited Members