- Home /
What Does "ExecuteInEditMode" Actually Do?
So, this is my first Unity project and also my first experience with Javascript, coming from a novice background in Python. I am currently building the "Lerpz" tutorial project, and I'm wondering what the "ExecuteInEditMode()" script does? Does it mean that the script will run even when the "Play" button hasn't been pressed? Or does it just mean that it will run within the Editor as opposed to a build? Specifically, shouldn't the menu show up even when the game isn't in "Play" mode?
Here's the code: @script ExecuteInEditMode() //Makes the script also execute in edit mode var gSkin : GUISkin; var backdrop : Texture2D; // our backdrop image goes in here private var isLoading = false; // if true, we'll display the "Loading..." message
function OnGUI() { if (gSkin) GUI.skin = gSkin; else Debug.Log("StartMenuGUI: GUI Skin object missing!");
var backgroundStyle : GUIStyle = new GUIStyle();//creates new GUIStyle object backgroundStyle.normal.background = backdrop;//makes the "normal.background" (a style element) to our background image
GUI.Label ( Rect( (Screen.width - (Screen.height 2)) 0.75, 0, Screen.height * 2, Screen.height), "", backgroundStyle); //creates screen that will remain proportional to screen size GUI.Label ( Rect( (Screen.width/2)-197, 50, 400, 100), "Lerpz Escapes", "mainMenuTitle");//creates a label on the screen
if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height - 160, 140, 70), "Play")) { isLoading = true; Application.LoadLevel("TheGame"); // load the game level. }
var isWebPlayer = (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer); if (!isWebPlayer) { if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height - 80, 140, 70), "Quit")) Application.Quit(); }
if (isLoading) GUI.Label ( Rect( (Screen.width/2)-110, (Screen.height / 2) - 60, 400, 70), "Loading...", "mainMenuTitle"); }
Thanks for any help and sorry for possible noob-ness.
Answer by kolban · May 15, 2012 at 05:45 PM
Here is the Internet manual page that describes "ExecuteInEditMode". This page seems to describe all that is needed. Have a read at the manual page and please feel free to come back with additional questions to clarify what you read at the manual page.
http://unity3d.com/support/documentation/ScriptReference/ExecuteInEditMode.html
Documentation has moved:
http://docs.unity3d.com/Documentation/ScriptReference/ExecuteInEdit$$anonymous$$ode.html
Your answer
Follow this Question
Related Questions
Manually triggering a script from the editor (utility, macro etc.) 1 Answer
How does the particle emitter update in edit mode? 1 Answer
Run script in Edit mode when paused? 3 Answers
Perform action on save/load in editor 2 Answers
Custom Asset Icons? 2 Answers