Update() in Editor script?

Is there any way I could get keyframe-like events within editor scripts?

I need to call a server-side script using the WWW class, and I need to check regularly its ‘isDone’ property.

I don’t want to use ‘yield’ (because I already have a system which only needs calling its Update() method regularly), and I don’t wan to use infinite while loops.

I’m looking the similar behaviour as MonoBehaviour.

Thanks!

Never used it personally, but

sounds like the kind of thing you are looking for.

The C# syntax would be something like:

[ExecuteInEditMode]
public class MyEditorClass
{

}

1 Like

Thx, I’ll try it ASAP.

Yap, it works, but the way it works isn’t what I expected (although it’s natural for performance reasons).

The update is called only when something is changed/clicked in editor (by developer). So it doesn’t suit my needs, since I need an action to be called N times per second.

Is there any other efficient way that I could call Update() method N times per second but it doesn’t break Unity? I’ve had no luck with Thread.Sleep() etc.

Thanks!

For a similar issue with one of my execute in edit mode scripts that needs continues OnGUI updates, i used the following hack in the OnGUI function:

transform.position += Vector3.zero;

This will fool Unity into continuous calls to OnGUI. I expect it would work just as well for Update. Note that we do seem to have some editor performance issues with scenes that include this hack on slower computers.

1 Like

Yes, I understand the performance issues completely. That’s why I’d like a time-liek behaviour. I don’t need it to run 100 times per second, just 5-10 times.

I’ll definitelly try this, but hoping to find an approach that allows me to fine-tune this FPS rate.

Thanks

Since i’ve found this thread a few times, i’m posting the link to what i’ll be looking for next time as well.

19 Likes