- Home /
Question by
Steven-1 · Jan 24, 2014 at 12:51 PM ·
editoreditorutilityprogressbar
How to use the ProgressBar (in an Editor script)?
Seriously, it seems easy, but it isn't working for me.
It's easy enough to display it, and have a correct progress value, but it never goes away unless I use the cancelable version, and press the cancel button. No idea why it doesn't go away when it is done, is I have put EditorUtility.ClearProgressBar(); after calculations are done, but it doesn't seem to do anything.
my code is like this more or less:
for (int x = minx; x < maxx; x++)
{
for (int y = miny; y < maxy; y++)
{
if (cancel)
{
EditorUtility.ClearProgressBar();
return null;
}
//do stuff
progress = (float)((x - minx) + (y - miny) * (maxx - minx)) / (float)(maxx - minx) * (maxy - miny);
cancel = EditorUtility.DisplayCancelableProgressBar("Doing stuff", "", progress);
}
}
EditorUtility.ClearProgressBar();
return something;
So why does the progress bar only go away when I cancel, but not when it's done?
Comment
Best Answer
Answer by Steven-1 · Jan 24, 2014 at 01:15 PM
I reduced the number of times the progressbar updates, and now it does work. Seems like a bug/restriction in Unity, updating the progressbar too often seems to make it break I think.