Uncompressed Texture for GUI Doesn't Display

I am using a texture to display text in a specific font and font size on the screen as a part of the GUI. The texture is too big because it covers the main character during game play. I’ve been trying to resize the texture in the start function, but the texture doesn’t display when I do. (The texture does display when I do not try to resize the texture) Here’s my code for resizing the texture:

var xGUITexture : Texture2D;

function Start (){
    	xGUITexture.Resize(Screen.width/2,Mathf.RoundToInt(Screen.width * 0.3),xGUITexture.format,true);

Am I using the wrong texture format? What would cause the texture not to appear? (I’m not showing the calls for showing the texture because they are working with the texture when it is not resized).

Oh, just noticed this myself.

Reading documentation does help: “After resizing, texture pixels will be undefined.

So texture.Resize() does not rescale your texture, it simply changes the dimensions and provides the memory adaption, but deletes the content.

And since non-uniform scales of a GUI.Label’s Rect() are apparently (and unfortunately) ignored, your best option is to leave the texture alone, and scale your GUI:

function OnGUI(){
    // store original matrix
    var guiMatrix:Matrix4x4=GUI.matrix;

    // where the label should be placed
    var labelRect:Rect=Rect(xPos,yPos,xGUItexture.width,xGUItexture.height);

	// scale GUI relative to current label size
	var scaleFactor:Vector2=Vector2(
            Screen.width/2 / labelRect.width,
            Mathf.RoundToInt(Screen.width * 0.3) / labelRect.height);

    // scale GUI around center of label
    GUIUtility.ScaleAroundPivot(scaleFactor, labelRect.center);

	// place label

	// reset GUI scaling

    // other GUI stuff, un-scaled
    // [...]

As I said, I don’t really use UnityGUI, so no guarantees :wink: