Weird GUI.

Hello,

I’m having a weird, a very weird, problem with my GUI. I have a plain black texture that fades in. That texture should always be exactly the same size as the screen. Now, I got 2 levels, in level 1 everything works perfectly, but then level 2…the GUI size gets all messed up, so does the text(same question). Everything is dragged in from a prefab.

This is my script(shortened but the essentials are there):

function Start () {

var edgeMargin = Screen.width * .01;


//making the end screen big enough
var guihelp : Rect = Rect(0, 0, Screen.width, Screen.height);
nextlvlGUI.transform.localScale = Vector3.zero;
nextlvlGUI.pixelInset = guihelp;
nextlvlGUI.pixelInset.x = nextlvlGUI.pixelInset.width / -2;
nextlvlGUI.pixelInset.y = nextlvlGUI.pixelInset.height / -2;

}

Here’s the web version of the game so far: Ball Brawl

Movement is with the mouse.

Use the new but-not-that-new-anymore GUI system, GUI.DrawTexture and Label stuff, instead of GUIText and GUITextures. They are dependant of their Transform and of the gameobject’s hierarchy, it can be tricky.

Just set the scale of the GUITexture to x = 1, y = 1, then it will always be the size of the screen without having to code anything. Don’t mess with the pixel inset stuff, set it all to 0.