- Home /
GUI problem
Hi!
I have a little problem with my battery script for my flashlight. I have a battery bar on the top left of my screen, when I press f the bar goes down as it supose to do.
The problem is when it's going down. It's like the texture I'm using as the bar, compresses and it looks really ugly. I want it to be like it removes small parts of it so it cuts parts of the texture instead compresses it.
Does anyone know how to fix this problem?
The GUI:
function OnGUI ()
{
GUI.DrawTexture(new Rect( 30, 50, 4.05 * energy, 25 ), BatteryTexture );
GUI.DrawTexture(new Rect( 30, 50, 405, 25 ), border );
}
Answer by Scribe · Apr 21, 2014 at 11:10 AM
I'm hoping this will be fixed in the new unity GUI system that should be around soonish, for now the work around (that I know of) is to use GUI groups and resize those:
function OnGUI (){
GUI.BeginGroup(new Rect(30, 50, 4.05*energy, 25));
GUI.DrawTexture(new Rect(0, 0, 405, 25), BatteryTexture);
GUI.EndGroup();
GUI.DrawTexture(new Rect( 30, 50, 405, 25), border);
}
I was quite sure where the border ought to be put, but thats how to resize the BatteryTexture.
Scribe
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Pause Menu background problem 0 Answers
Gui placement help 1 Answer
Pause Menu 5 Answers