- Home /
How to cut image horizontally using DrawTextureWithTexCoords?
So basically I have a stamina-bar in my game, represented by a picture, and it should cut downwards. But what it actually does is move downwards a bit, and then cut from there. I see this because I have a similar image, but stationary, behind it, to show when it empties.
This is the code for the stamina-bar:
GUI.DrawTextureWithTexCoords(new Rect(430, Screen.height, 100, -staminaLength), staminaBar2, new Rect(0,0, 1.0f, (staminaLength)/100), true);
And this is the code for the health-bar, which goes horizontally, but actually works, and uses the same principles:
GUI.DrawTextureWithTexCoords(new Rect(-80, 432, healthBarLength*5, 250), hpBar, new Rect(0,0,(healthBarLength*5)/500, 1.0f), true);
I know the images are being flipped upside down here, but yeah. Help would be appreciated.