Application.isPlaying Manual     Reference     Scripting  
Scripting > Runtime Classes > Application
Application.isPlaying

static var isPlaying : boolean

Description

Returns true when in any kind of player (Read Only).

Returns true in the Unity editor when in play mode.

JavaScript
if (Application.isPlaying) {
print("In player or playmode");
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Example() {
if (Application.isPlaying)
print("In player or playmode");

}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Example():
if Application.isPlaying:
print('In player or playmode')