- Home /
What's the C# equivalent of @script ExecuteInEditMode() ?
What's the C# equivalent of the javascript @script ExecuteInEditMode() ?
Answer by Chad · Oct 19, 2009 at 11:42 PM
Here is an example taken from one of my classes.
using UnityEngine;
[ExecuteInEditMode()]
public class MyBehaviour : MonoBehaviour
{
public void Update()
{
// Will run in edit mode. }
}
Answer by PsychicParrot · Oct 19, 2009 at 10:57 PM
You simply put:
[ExecuteInEditMode]
At the top of your script.
@DaBossT$$anonymous$$R: Nice job resurrecting a 3.5 years old question. JFYI: He was last seen on "Jan 2011".
Furthermore his answer isn't correct because attributes always belong to the statement that follows them. It has to be placed right before the class declaration and not at the top of the script. That's how attributes works in general. In UnityScript they just needed a workaround since the class is auto-generated by Unity, so you can't place the "@ExecuteInEdit$$anonymous$$ode" in front of the class. That's why they introduced "@script".
Your answer
![](https://koobas.hobune.stream/wayback/20220613154713im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
EditorWindow visibility 0 Answers
Adding/removing objects in editor mode 1 Answer
How do I make a progress bar in the editor lock the background? 0 Answers
Deleting prefab located in Project in scripts 0 Answers
Undo.RecordObject isn't working. 7 Answers