- Home /
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 .
Answer by BMayne · Sep 04, 2015 at 05:46 PM
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,
I really really appreciate the solid concise answer. So i'm i'm seeing too much overhead then I need to revise my code .
I will take your word and go with through with calling Repaint(); every frame.
Sometimes for larger editor I break stuff into tabs but this completely depends on the type of tool you are making. Also try to break away from creating stuff in OnGUI or any thing like GetComponent. On GUI gets called a ton of times per frame and this can really bog you down.
Cheers,
Your answer
Follow this Question
Related Questions
Listen to Keyboard Events on EditorWindow 1 Answer
Initialising List array for use in a custom Editor 1 Answer
Editor Windows - Where to get started? 1 Answer
OnGui elements as objects? 2 Answers
Close script tab in VS, from script 0 Answers