Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


isPlaying

Returns true when called in any kind of built Player, or when called in the Editor in Play mode (Read Only).
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public static bool isPlaying { get; }

Remarks

In a built Player, this method always returns true.
In the Editor, it returns true if the Editor is in Play mode.
Unity might throw an exception when
Application.isPlaying
is accessed in the class constructor or its value is assigned to a variable.
Note: In the Editor for ScriptableObject assets, this property returns false in OnEnable. After reloading the domain, when reloading assemblies, Unity invokes OnEnable on all ScriptableObject instances. This happens before isPlaying is set to true.
Additional Resources: Application.IsPlaying, ExecuteAlways.

Examples

using UnityEngine;class Example : MonoBehaviour{ void Start() { if (Application.isPlaying) { print("In player or playmode"); } }}