ExecuteInEditMode execute function only in play mode

Hi guys,

I have a Monobehaviour script assigned to a GameObject for editing some objects in edit mode.

When I press run I wish that some methods run only in the game mode.

I tried:

#if UNITY_EDITOR

#endif

but doesn’t work…

Doesn’t work how? Pressing ‘run’ only happens in Editor, so you must be in the Editor.

2 Likes

Thx! It works :slight_smile:

If you only want certain things in the Build, you can also use if (!Application.isEditor) or #if !UNITY_EDITOR.

1 Like