Scale GUI Texture to current screen size?

I’m making a 2D game for Android. Currently the game looks fine when the Game View is set to 800 x 480. But I am trying to get my GUI Textures to scale up or down according to the screen size.

My GUI textures are all 800 x 480 in size.

In the Unity Inspector, the Pixel Insets for my GUI Textures are set to X = -400, Y = -240.

Here’s what I have as far as code:

var player1WinsGUI : GUITexture;

function Update(){
//Scaling textures
player1WinsGUI.transform.localScale = Vector3(0, 0, 0);
}

I am trying to come up with a formula that will scale the texture to the current screen resolution, which I know I can get using Screen.width and Screen.height. My guess was:

Vector3(Screen.height/800, Screen.width/480, 0);

But that results in positive values, which make the texture way too large.

  1. Would this have anything to do with the way I have the Pixel Inset properties set in the inspector?

  2. Does anyone know which units the Vector3 parameters are in? Is it pixels, percentage or something else?

  3. Any ideas on how to do this the way I’ve set it up? Or is there a simpler way?

Thank you in advance!

Set all pixel inset values to 0, and just set the scale to x=1, y=1 (and position to .5, .5). Then it will always use the entire screen regardless of resolution. GUIText and GUITextures use viewport space.

hello this solved almost all my problems, however I have an image with 88x179px, but when I do that and care she is cool but when it fits a screen unless the image is very pixelated.

appreciate the help