Legacy Documentation: Version 5.6 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorGUI.ProgressBar

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function ProgressBar(position: Rect, value: float, text: string): void;
public static void ProgressBar(Rect position, float value, string text);

Parameters

totalPosition Rectangle on the screen to use in total for both the control.
value Value that is shown.

Description

Make a progress bar.

Value goes from 0 to 1, where 0 means 0% of the bar filled and 1 means the bar is at 100% fully filled


Progress bar in an Editor Window.

#pragma strict
// Draw the armor and damage with bars in an Editor Window
public class EditorGUIProgressBar extends EditorWindow {
	var armor: float = 20;
	var damage: float = 80;
	@MenuItem("Examples/Display Info")
	static function Init() {
		var window: EditorWindow = GetWindow(EditorGUIProgressBar, false, "DisplayInfo");
		window.Show();
	}
	function OnGUI() {
		armor = EditorGUI.IntSlider(new Rect(3, 3, position.width - 6, 15), "Armor", Mathf.RoundToInt(armor), 0, 100);
		damage = EditorGUI.IntSlider(new Rect(3, 25, position.width - 6, 15), "Damage", Mathf.RoundToInt(damage), 0, 100);
		EditorGUI.ProgressBar(new Rect(3, 45, position.width - 6, 20), armor / 100, "Armor");
		EditorGUI.ProgressBar(new Rect(3, 70, position.width - 6, 20), damage / 100, "Damage");
	}
}
using UnityEngine;
using System.Collections;
using UnityEditor;

// Draw the armor and damage with bars in an Editor Window

public class EditorGUIProgressBar : EditorWindow { float armor = 20; float damage = 80;

[MenuItem("Examples/Display Info")]

static void Init() { EditorWindow window = GetWindow(typeof(EditorGUIProgressBar), false, "DisplayInfo"); window.Show(); }

void OnGUI() { armor = EditorGUI.IntSlider(new Rect(3, 3, position.width - 6, 15), "Armor", Mathf.RoundToInt(armor), 0, 100); damage = EditorGUI.IntSlider(new Rect(3, 25, position.width - 6, 15), "Damage", Mathf.RoundToInt(damage), 0, 100);

EditorGUI.ProgressBar(new Rect(3, 45, position.width - 6, 20), armor / 100, "Armor"); EditorGUI.ProgressBar(new Rect(3, 70, position.width - 6, 20), damage / 100, "Damage"); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961