- Home /
simple gui question
hello, i have this code for a vertical gui progress bar which works pretty well. however the progress bar fills up from top to bottom. can someone help me to change it to the opposite - namely filling from bottom to top?
here is the code :
#pragma strict
var barDisplay : float = 0;
var pos : Vector2 = new Vector2(20,40);
var size : Vector2 = new Vector2(20,60);
var progressBarEmpty : Texture2D;
var progressBarFull : Texture2D;
var scalemax : float = 100;
function OnGUI()
{
GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
GUI.DrawTexture (Rect (0,0, size.x, size.y),progressBarEmpty);
GUI.BeginGroup (new Rect (0, 0, size.x, size.y * barDisplay));
GUI.DrawTexture (Rect (0,0, size.x, size.y),progressBarFull);
GUI.EndGroup ();
GUI.EndGroup ();
}
function Update()
{
barDisplay = score.gameScore/scalemax;
}
Answer by fafase · Jun 03, 2014 at 07:42 AM
You could try to rotate the GUI http://docs.unity3d.com/ScriptReference/GUIUtility.RotateAroundPivot.html
Answer by Zodiarc · Jun 03, 2014 at 07:45 AM
I can check it right now but he basic idea is, that you fill it from top to bottom and move it down to the lowest position and repeat this every time the bar updates. It will happen within one frame so the player won't be able to see it anyway.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Setting Scroll View Width GUILayout 1 Answer
Health Bar Only For Falling Damage 2 Answers
Mouse ignore object 2 Answers
Two Unity GUI questions 2 Answers