Moving scripts from run-time edit to editor mode edit

Hey. I’ve written some script components which I’ve tested out in-game via a GUI interface which edits the setup of the components.

Now I have reached a point of satisfactory functionality, so I wish to move the editing part out of the in-game context and into the editor.

Since my script components need to both function in the editor and in-game (only with different functionality based on the same data), the [ExecuteInEditMode] option looks like what I’d want.

My trouble is I have no way of determining whether the script is running while in editor mode or if it is running in the game from the editor. If I could make this distinction then I could provide the correct functionality.

Does my approach make sense or does anyone have a better alternative? If no then does anyone have any idea how to make the distinction between the two modes?

Also I’ve noticed my GUI is shown in the game window and not the editor even though the script is running in editor mode.

Is there a way to make the GUI render in the editor window or does the editor window use another GUI interface than the run-time window?

Is there a solution to this now?

EDIT:

I meant to ask if there is a way to find out if a script runs in edit mode or game mode.

Hi, welcome to the forum!

Check out EditorApplication.isPlaying.

Nice, thank you!

I remember coming across this but forgot about it and couldn’t find it when searching the script reference.

Wow. Talk about resurrection here. I think this is was one of my first questions here - a short while after I first started playing around with Unity :wink: