- Home /
GUI Group clipping
I would like to have a progress bar - following the suggestions in the documentation, I am implementing this with a pair of Gui groups and clipping the inner one, like so:
GUI.BeginGroup(Rect(25,525,100,20));
GUI.Label(Rect(0,0,100,20), progressBackground);
GUI.BeginGroup(Rect(0,0,progressFraction*100, 20));
GUI.Label(Rect(0,0,100,20), progressForeground);
GUI.EndGroup();
GUI.EndGroup();
Where progressFraction decreases from 1.0; and progressForeground and progressBackground are textures 100x20 in size.
My first version used Box instead of Label, but I didn't like the big outset rounded corners. In both Box and Label, however, I am seeing that the clipping boundary starts at some x value larger than 100 - in my particular case this means there is a 'dead time' where the bar does not appear to be updating, but the clipped region is to the right of the texture.
I thought that it was maybe a Skin / Style issue, as I have no GUI Skin associated with the GUI GameObject / Component, and I haven't used one in the label. I made a new Gui Skin and set the Margin and Padding in the left-right direction to zero. However, that didn't change the behavior - that clipping seems to start out of the visible region.
Any clues what I'm missing?
Answer by andeeee · Jan 14, 2010 at 01:13 PM
Try using GUI.DrawTexture to draw the progress bar textures. I think GUI.Label assumes a thin border region that causes trouble when you need to position things exactly.
Your answer
Follow this Question
Related Questions
Scrolling Text 1 Answer
Opening a second gui 1 Answer
Button Turns Off and On Object 1 Answer
Wearied Error 1 Answer
text field - inputting numbers only 1 Answer