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.
-
Would this have anything to do with the way I have the Pixel Inset properties set in the inspector?
-
Does anyone know which units the Vector3 parameters are in? Is it pixels, percentage or something else?
-
Any ideas on how to do this the way I’ve set it up? Or is there a simpler way?
Thank you in advance!