- Home /
How to force Unity to Repaint an EditorWindow?
Hi, I have a problem with the OnGUI method:
In an EditorWindow class, I have
void OnGUI()
{
_loadingDots += ".";
if(_loadingDots.Length >= 4)
_loadingDots = ".";
GUILayout.Label("Importing" + _loadingDots, EditorStyles.boldLabel);
Repaint();
}
And in the Update:
void Update()
{
_timer += Time.deltaTime;
if(!_isProcessBusy)
{
if(_timer >= 0.5f)
_isProcessFree = true;
}
if(_isProcessFree)
{
_isProcessFree = false;
_isProcessBusy = true;
Import();
}
}
The problem is that when the Import() method is called the GUI freezes, but when the Import method finish then it repaints, How could I force to repaint? I know I'm using the Repaint method, but it seems doesn't work or the OnGUI or Update are not called until the Import method finish.
Answer by Slobdell · Jan 23, 2014 at 11:26 PM
Whatever your import method is doing is blocking the thread until finished. You'll need to fire it off on another thread so the rest game doesn't have to wait for it to finish to proceed.
Your answer
Follow this Question
Related Questions
How to draw button in editor window rotated by 90 degrees? 0 Answers
Huge Performance difference between docked and undocked EditorWindow 0 Answers
DragAndDrop EditorGUILayout.Box ? 1 Answer
Use of the inspector along with a custom editorwindow 1 Answer
How do I make a progress bar in the editor lock the background? 0 Answers