- Home /
What is the best way to resize textures on the GUI?
I'm trying to work on a menu system for my game and gotten things to the point it moves posistion properly, but what is the best way to dynamically resize textures for multiple resolutions?
Answer by robert_mathew · Jan 13, 2012 at 03:11 AM
public Texture p_medal_texture;
void OnGUI()
{
GUI.DrawTexture(new Rect(Screen.width * (3.4f/6.55f),Screen.height * (1.1f/6.3f),Screen.width * (1f/6.55f), Screen.height * (1f/6.3f)),p_medal_texture,
ScaleMode.StretchToFill, true, 100.0F);
}//c# script
var p_medal_texture : Texture ;
function OnGUI ()
{
GUI.DrawTexture( Rect(Screen.width * (3.4f/6.55f),Screen.height * (1.1f/6.3f),Screen.width * (1f/6.55f), Screen.height * (1f/6.3f)),p_medal_texture,
ScaleMode.StretchToFill, true, 100.0F);
}//java script
using this script dynamically resize textures for multiple resolutions and you can also use same for any gui so that it will dynamically resize for multiple resolutions if this is the solution for your problem means up vote it.
Hmm, it worked partially but the resize reduced the graphic drastically. I'm not looking for posistioning.. just size.
What I'd like to do is basically keep the aspect ratio but scale down to match the screen.
Answer by Daniel 6 · Jan 13, 2012 at 02:51 AM
Change the main matrix of the GUI class. I usually use GUIUtility.ScaleAroundPivot () for my scaling.