# OnEnteringPlayModeAttribute

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

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class OnEnteringPlayModeAttribute : LifecycleAttributeBase
```

## Remarks

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](/engine/6000.5/script-reference/unityengine/onexitingplaymodeattribute.md), [RuntimeInitializeOnLoadMethodAttribute](/engine/6000.5/script-reference/unityengine/runtimeinitializeonloadmethodattribute.md), AfterManagedObjectsRestoredAttribute.

## Examples

```csharp
using UnityEngine;

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

## Constructors

| Constructor                                                                                                      | Description                                                              |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [OnEnteringPlayModeAttribute()](/engine/6000.5/script-reference/unityengine/onenteringplaymodeattribute/ctor.md) | Marks the decorated static method to be invoked when entering Play mode. |
