ProgressBar
示例程序 | |
---|---|
说明 | 生成一个进度条 |
用法
public static void ProgressBar(Rect position, float value, string text);
参数
position
进度条的绘制区域。
value
进度条当前对应的数值。
text
进度条内部显示的文本。
示例
void OnGUI () {
_float = Mathf.Max (_float, 0);
_float = Mathf.Min (_float, 100);
_float = EditorGUI.FloatField (new Rect(5, 5, 400, 17), "Precentage", _float);
EditorGUI.ProgressBar (new Rect (5, 27, 400, 17), _float / 100, "Progress");
if (GUI.Button(new Rect(5, 49, 400, 17), "Start")) {
_start = true;
}
if (GUI.Button (new Rect (5, 71, 400, 17), "Reset")) {
_float = 0f;
_start = false;
}
}
void Update () {
if (_start) {
_float += 0.1f;
}
if (_float >= 100f) {
_start = false;
}
Repaint ();
}