Weird GUI.Label behavior

Well ofcourse it can be my own weird code, but let me beleive it is not for now.

So I am trying to change the size of a drawn texture2D over time.
Within the OnGUI function I do this:
Rect area = new Rect(0,0,x,1024);
GUI.Label(area, originalTexture,“”);

Note:

  1. Within the class scope:
    public Texture2D originalTexture;
  2. I change the ‘x’ variable in the update function from 0 to 117 (with a Mathd.SmoothStep function).

My problem is, the image is not drawn with the constant 1024 height, instead it changes from 0 to 1024!

What am I missing here?

It seems like the texture can not be displayed but in the original aspect ratio.
Am I right?
Can I not change the ratio in run time?

So it seems that if I use GUI.DrawTexture instead of GUI.Label, I do get the result I want, and that is streching the image only towards one direction.

However, in an application I use many of these calls and I get alot more draw calls when using DrawTexture instead of Label.
Am I correct to say, that when the size of the rectangle used is 0 in width and height, the DrawTexture is still done, while the Label is not actually done, resulting in much more draw calls when using DrawTexture?

why would you have a DrawTexture of 0,0 size?..

You could check in the rendering stat window if the value changes when you use the draw texture and when you dont :slight_smile:

I did that, but obviously you don’t need this check when using GUI.Label, so I’m guessing that if I actually did this check even when only using GUI.Label, I would be doing a check that was already done (as GUI.Label of zero size does not produce a draw call).