Is this a bug? Can't click when using @script ExecuteInEditM

Not sure if this is a bug or something I’ve done wrong but it caught me out for a while.

When using @script ExecuteInEditMode() at the top of a script then this works most of the time (for OnGui stuff).
But if I have Application.LoadLevel(“name”); in the same script it sometimes stops the Unity application from allowing me to click in the Hierarchy or Project Pane and select anything. I click and it immediately deselects it.

This makes Unity then become unusable for that whole scene.

If i comment out the @script Execute… line then all is fine but is there somewhere special that the Application.LoadLevel should go? I have it inside the OnGui function.

Figured it out I think. The Application.LoadLevel is trying to execute in the Unity editor. This only works where I have a button with if…
So I guess it is trying to load a new scene and Unity doesn’t like that if it’s not playing the scene.