Select your preferred scripting language. All code snippets will be displayed in this language.
Namespace: UnityEngine
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseMakes a script execute in edit mode.
By default, script components are only executed in play mode. By adding this attribute, each script component will also have its callback functions executed while the Editor is not in playmode.
The functions are not called constantly like they are in play mode.// Make the script also execute in edit mode. @script ExecuteInEditMode()// Just a simple script that looks at the target transform. var target : Transform; function Update () { if (target) transform.LookAt(target); }
using UnityEngine; using System.Collections; [ExecuteInEditMode] public class ExampleClass : MonoBehaviour { public Transform target; void Update() { if (target) transform.LookAt(target); } }
import UnityEngine import System.Collections [ExecuteInEditMode] public class ExampleClass(MonoBehaviour): public target as Transform def Update() as void: if target: transform.LookAt(target)