Check if a script is running in editor or game

Hi guys,
quick question related to scripting:
There is a way to understand if a script is running in editor or in the game?
Basically my problem is that I have created a script which can be executed in editor more using the config

[ExecuteInEditMode]

And I’ve put some code into the OnRenderObject function.
The problem is that I want that this code only runs in the editor and not when the game is running.
There’s a quick solution for that?

Thank you guys

1 Like

Ok, I’ve found that the best way to detect if the game is actually running is to check the property Application.isPlaying.

if(Application.isPlaying){
    // The game is running
}
else {
   // The script is executing inside the editor
}

Is suggest you to use the Platform Defines. This will optimize a bit your app.