- Home /
GUITexture aspect ratio resize
How can i resize GUITexture according to the actual screen resolution maintaining its aspect ratio? I've already searched a solution of my problem, but I haven't found anything. Sorry for bad English, I'm italian. Thanks in advance
Answer by robertbu · Feb 07, 2014 at 08:49 PM
You just need to adjust the GUITexture.pixelInset rect.
it doesn't work well, i need that GUITextures can resize changing the screen resolution
pixelInset() allows you to change it, so the question is how you want it to change. I don't know the specific of your game. You may want something like this (untested):
var rect = guiTexture.pixelInset;
rect.width = rect.width * Screen.width / rect.width;
rect.height = rect.height * screen.height / rect.width;
rect.x = rect.width / 2.0;
rect.y = rect.height / 2.0;
guiTexure.pixelInset = rect;
Your answer
Follow this Question
Related Questions
Keeping a GUI texture from moving during change of screen size 2 Answers
Preview of screenshot in unity 2 Answers
GUI texture to fit the screen at any resolution? 4 Answers
Cutting off a GUITexture's texture 0 Answers
Resizing GUI textures 0 Answers