- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Firzenizer · Apr 01, 2013 at 01:22 AM ·
guiscalehealthbarscrollbar
GUI.HorizontalScrollbar won't change it's height
I have been trying to scale my health bar size with screen size, but for some reason I am unable to change the height. No matter what number I have on the "50 * scale.y" part it remains the same size.
It just gotta be something stupid I am not realizing.
// ## HEALTH BAR ##
//Health bar (black background)
GUI.backgroundColor = Color.black;
GUI.HorizontalScrollbar(Rect (
Screen.width/2-50 * scale.x,
Screen.height - 25,
100 * scale.x,
50 * scale.y),
0,
player.GetMaxHealth() * scale.x,
0,
100 * scale.x);
//Green health bar (green part)
GUI.backgroundColor = Color.green;
GUI.HorizontalScrollbar(Rect (
Screen.width/2-50 * scale.x,
Screen.height - 25,
100 * scale.x,
50 * scale.y),
0,
player.GetHealth() * scale.x,
0,
100 * scale.x);
Comment
I thought it would be a good idea. What would you use?
I ended up using GUI.DrawTexture.
// Drawing the background
GUI.DrawTexture(Rect(screen.x/2-50 * scale.x,screen.y - 25 * scale.y, player.Get$$anonymous$$axHealth() * scale.x + 4, 20 * scale.y + 4),
barBackground, Scale$$anonymous$$ode.StretchToFill, true, 10.0f);
// Drawing the health bar
GUI.DrawTexture(Rect(screen.x/2-50 * scale.x + 2,screen.y - 25 * scale.y + 2, scale.x * player.GetHealth(), 20 * scale.y),
bar, Scale$$anonymous$$ode.StretchToFill, true, 10.0f);
So it's not really a problem anymore, I suggest closing/deleting your question.
Your answer
![](https://koobas.hobune.stream/wayback/20220613095440im_/https://answers.unity.com/themes/thub/images/avi.jpg)