When is the best time to call Repaint(); in an editor window

In order to update the UI , I need to call Repaint(); , or EditorWindow.focusedWindow.Repaint();

However In the case of a simple button with an hover effect . If that button with an hover effect is being rendered in the editor window and I am not calling Repaint(); in my EditorWindow script , then I wont see the hover effect on the button when I move my cursor over it unless I leave the cursor in one position for a second or so ; so when the window automatically updates itself.

Right now I call Reapint(); whenever the mouse is down in the EditorWindow , but that too is not a good fix , as it will never allow for redrawing of UI if the cursor hovers over a button with an hover effect as i mentioned before.

I cant constantly call Reapint(); , it would make my editor window slow, but I would constantly have an updated UI .

I have no idea of how to work around this . When exactly do I call repaint ?

I really really dont want to constantly repaint my editor window when it in focus and there is no interaction with the UI because I will end up with more pressure on my CUP .

Hey there,

You can totally call repaint if you want to every frame, this is what it’s there for. The only reason it does not do it by default is the fact that editors are mostly static. If your editor is running slow you should most likely break it up anyway.

Cheers,