I am using the following code inside my OnGUI function so as to show part of my texture:
percentIndicatorRect.height = getPercentage() * indicator.height;
GUI.BeginGroup(percentIndicatorRect);
GUI.DrawTexture(indicatorRect, indicator);
GUI.EndGroup();
The thing is that it is showing a percentage of the texture only from the top through the bottom of the image.
For example, if getPercentage returns 0.35, 35% of the image will be shown from its top through the bottom.
I’ve understood pretty well how the BeginGroup function works and I cannot think of a way that I can make it show a percentage of the image from the bottom.
I’ve tried several things, like changing the value of the percentIndicatorRect.y (but then the whole texture moves along with it, so there is no use).
I have an idea of altering the percentIndicatorRect.y to += (1-percentage)*percentIndicatorRect.height (so as to move the “container” down and now its x, y values to be the upper left edge of the part of the image that I want to show) and then to abstract this value from indicatorRect.y (and thus it will take a negative value) (so as to move the texture up and place it to the right location)
But I have not implemented this because it doesn’t sound correct.