I everybody,
I’ve got a GUI texture used as background for some GUI elements.
I made a textre in 1280*800 to fit with the biggest smartphones screens, but this texture doesn&'t be resized when I use a smaller screen.
How could I do that ?
Tks
I everybody,
I’ve got a GUI texture used as background for some GUI elements.
I made a textre in 1280*800 to fit with the biggest smartphones screens, but this texture doesn&'t be resized when I use a smaller screen.
How could I do that ?
Tks
This is a common problem with most games, and every single Unity Game I’ve seen that uses GUI elements FAIL to resize the buttons for multiple resolutions. What if (On a standalone build, the player does NOT want to play in full screen?)
What you’re looking for is basically what I use for all my GUI code, with a few changes.
To make a re-sizable button, we look at this code here:
if (GUI.Button(Rect(.1 * Screen.width, .8 * Screen.height, .2 * Screen.width, .1 * Screen.height), "My Button"))
What you’re looking for is a texture that fills the whole screen, so we do a similar statement:
GUI.DrawTexture(Rect(0 * Screen.width, 0 * Screen.height, 1 * Screen.width, 1 * Screen.height), myTexture, ScaleMode.ScaleToFit, false, 0);
Which can be simplified to:
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), myTexture, ScaleMode.ScaleToFit, false, 0);