Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DevMerlin · Jan 13, 2012 at 02:46 AM · guitexture2dmenuresize

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DevMerlin · Jan 13, 2012 at 04:24 AM 0
Share

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.

avatar image Fattie · Jan 16, 2012 at 09:33 AM 0
Share

excellent answer thanks!

avatar image
1

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by DevMerlin · Jan 13, 2012 at 04:17 AM

ScaleAroundPivot()? Will that work with Texture2D?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image syclamoth · Jan 13, 2012 at 04:18 AM 1
Share

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

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make this GUI Bigger? 1 Answer

Uncompressed Texture for GUI Doesn't Display 1 Answer

Is there a way to import png images with TextureType = GUI automatically? 1 Answer

Game Menus WIth Keyboard Input Control 1 Answer

Accessing the Asset's setting from code using Wizards/Editor classes? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges