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");
}