A progress bar to display proportion completed of Editor extension processing
If an Editor task is going to take more than half a second or so, then we should indicate progress complete/remaining to the user via a progress bar so that they understand that something is actually happening and the application has not crashed and frozen.
Getting ready
This recipe adds to the previous one, so make a copy of that project folder and do your work for this recipe with that copy.
How to do it...
To add a progress bar during the loop (and then remove it after the loop is complete), replace the PlacePrefabs()
method with the following code:
static void PlacePrefabs(){ string assetPath = "Assets/Prefabs/prefab_star.prefab"; starPrefab = (GameObject)AssetDatabase.LoadMainAssetAtPath(assetPath); int total = 100; for(int i = 0; i < total; i++){ CreateRandomInstance(); EditorUtility.DisplayProgressBar("Creating your starfield", i + "%", i/100f); } EditorUtility...