# Update() in Editor script?

**URL:** https://discussions.unity.com/t/update-in-editor-script/416651
**Category:** Scripting
**Tags:** Scripting
**Created:** [June 25, 2010, 6:39pm UTC](https://discussions.unity.com/t/update-in-editor-script/416651 "2010-06-25T18:39:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dkozar](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dkozar/32/563194_2.png) [@dkozar](https://discussions.unity.com/u/dkozar)
#### Post date: [June 25, 2010, 6:39pm UTC](https://discussions.unity.com/t/update-in-editor-script/416651/1 "2010-06-25T18:39:52Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![anon\_67940662](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@anon\_67940662](https://discussions.unity.com/u/anon_67940662)
#### Post date: [June 25, 2010, 6:54pm UTC](https://discussions.unity.com/t/update-in-editor-script/416651/2 "2010-06-25T18:54:47Z")

</div>

Never used it personally, but

> **[Unity - Scripting API: ExecuteInEditMode](https://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html)**

sounds like the kind of thing you are looking for.

The C# syntax would be something like:

[ExecuteInEditMode]  
public class MyEditorClass  
{

}

---

<div class="post-metadata">

### Author: ![dkozar](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dkozar/32/563194_2.png) [@dkozar](https://discussions.unity.com/u/dkozar)
#### Post date: [June 25, 2010, 7:40pm UTC](https://discussions.unity.com/t/update-in-editor-script/416651/3 "2010-06-25T19:40:38Z")

</div>

Thx, I’ll try it ASAP.

---

<div class="post-metadata">

### Author: ![dkozar](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dkozar/32/563194_2.png) [@dkozar](https://discussions.unity.com/u/dkozar)
#### Post date: [June 30, 2010, 8:03am UTC](https://discussions.unity.com/t/update-in-editor-script/416651/4 "2010-06-30T08:03:25Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![tomvds](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@tomvds](https://discussions.unity.com/u/tomvds)
#### Post date: [June 30, 2010, 8:19am UTC](https://discussions.unity.com/t/update-in-editor-script/416651/5 "2010-06-30T08:19:02Z")

</div>

> [@""](#):
>
> 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:

```auto
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.

---

<div class="post-metadata">

### Author: ![dkozar](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dkozar/32/563194_2.png) [@dkozar](https://discussions.unity.com/u/dkozar)
#### Post date: [June 30, 2010, 8:44am UTC](https://discussions.unity.com/t/update-in-editor-script/416651/6 "2010-06-30T08:44:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![DgoodingIndi](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dgoodingindi/32/920861_2.png) [@DgoodingIndi](https://discussions.unity.com/u/DgoodingIndi)
#### Post date: [January 13, 2022, 2:15am UTC](https://discussions.unity.com/t/update-in-editor-script/416651/7 "2022-01-13T02:15:41Z")

</div>

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.

> **[How do i get a callback every frame in edit mode](https://discussions.unity.com/questions/39313/how-do-i-get-a-callback-every-frame-in-edit-mode.html)**
>
> I dont want to use an Editor Window or ScriptableObject or MonoBehaviour. I just want to get a callback called every frame without having the user having to click a menu item or something like that.
