ExecuteInEditMode unity3

it seems that ExecuteInEditMode doesnt work in unity3, cuz I always used this tag in 2.6, everything worked fine. And now Update in script with ExecuteInEditMode is called only in some cases like when you click hierarchy screen, or reimport script and so on… and this is bad (((

here’s lil snipet I use for testing.

[ExecuteInEditMode]
public class Test : MonoBehaviour
{
	public void Update()
	{
		print(Event.current);
		if (Input.GetMouseButton(0))
			print("Hello");
	}
}

As I have said in some cases it prints “null” as current event, but prints it portionally, by 1-3 lines. And only when I make some actions in editor.

AFAIK the editor only updates when something has changed to keep CPU usage low.


oxl

or maybe I got that wrong?

it works fine for me, it won’t update continously though.

what I’m not sure if it does anything in this context is event checking cause the events actually should be processed and like also eaten by the editor as you are effectively in the editor not in play mode so editor has always priority

well, so how can I check in editor that I clicked a mouse?

as for my code example - I tried simple update like

but it doesnt work either

also, referense says:

how should I understand this?

ExecuteInEditMode is a bit limited because there isn’t a regular frame update in the editor like there is during gameplay. If you want to execute code at regular intervals in the editor, you can use the EditorApplication.Update delegate. To use it, just declare a function with no parameters and assign its name to the property:-

void MyUpdateFunc() {
   // Update code.
}
  ...
EditorApplication.update = MyUpdateFunc;
  ...

thanx for you advice, andeeee )
well, I think I’d better go another way and use editor scripts, that should work for me.

For me, update is called only when the objet containing the script is in the camera field.