OverviewUIProgressBar is the base class that both the
UISlider and the
UIScrollBar inherit from. You can also use it by itself to create progress bars -- sliders without a thumb.

The only thing a UIProgressBar requires to function is a refrence to the
Foreground widget. This widget should be of the absolute maximum dimensions the progress bar will be allowed to occupy, which is what happens when its
Value is at 1.0 (100%).
To create a very simple progress bar, just create a
sliced sprite and give it a width of 300 with the height of 20.
Next, add a UIProgressBar script to that sprite (the background), and set up the
Foreground field accordingly. At this point you can hit Play and adjust the values in the Inspector window, and the sprite should react accordingly.
To change the direction in which the progress bar will increase as its value goes from 0 to 1, change the
Direction field.
If you want the progress bar to be interactable, have a look at the
UISlider component.
In the
OnValueChange section you can specify a function that will be called when the progress bar's value changes. If you've added the label somewhere, you can easily reference its
SetCurrentPercent function, and the label's value will show the Progress Bar's value in percent. To do this, drag & drop the Label's game object into the
Notify field and then choose the UILabel.SetCurrentPercent function from the drop-down list.
To make a custom function eligible for On Value Change, simply make it of type "public void FuncName ()" like so:
public void MyFunc () { Debug.Log(UIProgressBar.current.value); }
Pro-Tip #1You are not limited to using sprites for the progress bar's foreground. One interesting example would be to use a
UILabel set to "ClampContent" overflow and Max Lines of 1. The label's text will be filled as the progress bar's value increases.
Pro-Tip #2You can add OnChange delegate listeners via code by using EventDelegate.Add, just like with everything else:
public class Test : MonoBehaviour
{
void Awake()
{
UIProgressBar pg = GetComponent<UIProgressBar>();
EventDelegate.Add(pg.onChange, MyFunc);
}
void MyFunc ()
{
Debug.Log(UIProgressBar.current.value);
}
}
Class Documentationhttp://tasharen.com/ngui/docs/class_u_i_progress_bar.htmlIf you have a question regarding this component or would like me to clarify something, just post a reply here.