I have a custom progress bar window setup. It works and everything, but it only shows 0 and 100 percent nothing in between, no updating of the bar. Here’s my Code.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class AIS_BuilderProgress : EditorWindow
{
public AIS_GameController gController;
public AIS_DBEditorWindow dbEditor;
public float progress;
public string dialog = "";
public string log = "";
private Vector2 scrollPos;
public int successCount;
public int skipCount;
void Run ( )
{
AIS_ItemDatabase database = gController.itemDataBase;
AIS_BaseItem[] itemList = database.gameItems.ToArray ( );
int ItemsStartCount = itemList.Length;
for ( int i =0; i < itemList.Length; i++ )
{
Refresh ( );
dbEditor.BuildPrefab ( itemList [ i ], i, true );
progress = ( i+1 )/itemList.Length;
dialog = "Building : " + itemList [ i ].itemName;
log += "
“+database.gameItems [ i ].itemName + " was built successfully…”;
successCount++;
dialog = “Finished!”;
log += "
" + successCount + " successful, " + skipCount + " skipped, and " + ( itemList.Length - ( successCount+skipCount ) ) + " failed out of " + itemList.Length + " total.“;
}
}
void OnGUI ()
{
GUI.Label(new Rect ( 5, 5, 420, 20 ),dialog);
if ( GUI.Button ( new Rect ( 360, 5, 60, 15 ), “Build” ) )
{
Run ( );
}
if ( GUI.Button ( new Rect ( 425, 5, 60, 15 ), “Close” ) )
{
dbEditor.buildingObjects = false;
this.Close ( );
}
EditorGUI.ProgressBar ( new Rect ( 5, 25, 490, 30 ), progress, “” + ( progress*100 )+”%" );
float dialogHeight = GUI.skin.GetStyle(“Label”).CalcSize(new GUIContent(log)).y;
GUI.Box ( new Rect ( 5, 60, 490, 80 ), “” );
scrollPos = GUI.BeginScrollView ( new Rect (5,60,490,80), scrollPos, new Rect ( 5, 60, 475, dialogHeight) );
GUI.Label ( new Rect ( 5, 60, 490, dialogHeight ), log );
GUI.EndScrollView ( );
}
public void Refresh()
{
this.Repaint ( );
}
}
As stated above, I WAS able to update the loading progress in the editor. But thank you.
– slkjdfv