ScriptReference/EditorUtility.ClearProgressBar #279
Replies: 1 comment
-
|
Comment by You should always wrap your progress bars in a try finally. This is because if you have an exception the clear will never be called. If you don't call clear the user will have to force close Unity to dismiss it. This makes sure that never happens. public void PrintGameObjectNames()
{
try
{
GameObject[] gameObjects = GameObject.FindObjectsOfType<GameObject>();
for(int i = 0; i < gameObjects.Length; i++)
{
Debug.Log(gameObjects[i].name);
EditorUtility.DisplayProgressBar("Printing Game Objects", gameObjects[i].name, (float)i / gameObjects.Length);
}
}
finally
{
// Even if we have an exception the finally happens
EditorUtility.ClearProgressBar();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
ScriptReference/EditorUtility.ClearProgressBar
https://docs.unity3d.com/ScriptReference/EditorUtility.ClearProgressBar.html
Beta Was this translation helpful? Give feedback.
All reactions