x


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?

more ▼

asked Jan 13, 2012 at 02:46 AM

Teonnyn gravatar image

Teonnyn
147 122 780 148

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first
    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.

more ▼

answered Jan 13, 2012 at 03:11 AM

robert_mathew gravatar image

robert_mathew
509 97 99 132

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.

Jan 13, 2012 at 04:24 AM Teonnyn

excellent answer thanks!

Jan 16, 2012 at 09:33 AM Fattie
(comments are locked)
10|3000 characters needed characters left

Change the main matrix of the GUI class. I usually use GUIUtility.ScaleAroundPivot () for my scaling.

more ▼

answered Jan 13, 2012 at 02:51 AM

Daniel 6 gravatar image

Daniel 6
541 9 7 23

(comments are locked)
10|3000 characters needed characters left

ScaleAroundPivot()? Will that work with Texture2D?

more ▼

answered Jan 13, 2012 at 04:17 AM

Teonnyn gravatar image

Teonnyn
147 122 780 148

Could you post this as a comment, not an answer?

Jan 13, 2012 at 04:18 AM syclamoth
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5631
x608
x591
x145

asked: Jan 13, 2012 at 02:46 AM

Seen: 2448 times

Last Updated: Jan 16, 2012 at 09:33 AM