Hi there, I’m writing a GUI sytem. In this system I want to be able to move the position of GUI elements, using viewport coordinates rather than world space (so there positions will be correct across multiple resolutions) and see the results in the editor immediately. To try and achieve this I’m using [ExecuteInEditMode] and the following code in my update:
#if UNITY_EDITOR
transform.position = referenceToGUICamera.ViewportToWorldPoint ( new Vector3 ( viewPorttarget.x, viewPorttarget.y, referenceToGUICamera.nearClipPlane ) );
#endif
So the first part of this works - I can change the viewporttarget and it updates it’s position while the game isn’t running, in the editor. However, it’s also running when the game is. I guess this is because of the [ExecuteInEditMode].
So I guess my question is, is there any way I can prevent this code from running when the game is, while still allowing it to run while Im in editor mode?
Thanks, any help much appreciated!