x


What's the C# equivalent of @script ExecuteInEditMode() ?

What's the C# equivalent of the javascript @script ExecuteInEditMode() ?

more ▼

asked Oct 19 '09 at 10:56 PM

PsychicParrot gravatar image

PsychicParrot
605 5 9 13

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.
    }  
}
more ▼

answered Oct 19 '09 at 11:42 PM

Chad gravatar image

Chad
176 5

(comments are locked)
10|3000 characters needed characters left

You simply put:

[ExecuteInEditMode]

At the top of your script.

more ▼

answered Oct 19 '09 at 10:57 PM

PsychicParrot gravatar image

PsychicParrot
605 5 9 13

Nice job answering your own question :P

Mar 11 at 10:37 PM DaBossTMR

@DaBossTMR: 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 "@ExecuteInEditMode" in front of the class. That's why they introduced "@script".

Mar 11 at 11:21 PM Bunny83
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x347

asked: Oct 19 '09 at 10:56 PM

Seen: 4620 times

Last Updated: Mar 11 at 11:21 PM