Version: 5.4 beta (switch to 5.3)
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

Sumbission failed

For some reason your suggested change could not be submitted. Please try again 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.

	// Draw the damage and the armor with bars in an Editor Window
	
	class EditorGUIProgressBar extends EditorWindow {
	
		var armor : int = 20;
		var damage : int = 80;
	
		@MenuItem("Examples/Display Info")
		static function Init() {
			var window = GetWindow(EditorGUIProgressBar);
			window.Show();
		}
		
		function OnGUI() {
			armor = EditorGUI.IntSlider(Rect(3,3,position.width-6,15), "Armor:", armor, 0, 100);
			damage = EditorGUI.IntSlider(Rect(3,25,position.width-6,15), "Damage:", damage, 0, 100);
			
			EditorGUI.ProgressBar(Rect(3,45,position.width-6,20),armor/100.0, "Armor");
			EditorGUI.ProgressBar(Rect(3,70,position.width-6,20),damage/100.0, "Damage");
			
		}
	}