• 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 Blink · Jan 05, 2013 at 04:27 PM · guitextureresolutionscreenfit

GUI texture to fit the screen at any resolution?

I am trying to add damage to my player, and when he does a GUI texture come up of blood around the edges of the screen, I have my texture but I cannot get it to stay in the place I want it to be in when the resolution changes. I cant really explain any more than this but these pictures should give you a better understanding. Sorry about the external links.

http://postimage.org/image/hh5wji1hp/

http://postimage.org/image/iamsb3bhv/

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

4 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Jan 20, 2013 at 11:49 PM

Make the GUITexture have an X and Y scale of 1.0. Set all pixel inset values to 0. Make sure the X/Y locations are 0.5.

Comment
Add comment · Show 6 · 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 Blink · Jan 22, 2013 at 05:22 PM 0
Share

When you mean have the X and Y scale of the texture set to 1 do you mean to set the width and height to 1, or do you mean another way?

avatar image Eric5h5 · Jan 22, 2013 at 05:38 PM 0
Share

I mean set the X and Y scale to 1. Objects have position, rotation, and scale. So, set the X and Y scale to 1. The Z scale is irrelevant.

avatar image Blink · Jan 22, 2013 at 05:47 PM 0
Share

Aha! works perfectly now, thanks.

avatar image Shivansh · Feb 07, 2014 at 12:59 PM 0
Share

sorry buddy, not working for me.

i tried as you told, x/y scale to 1 and x/y position to 0.5

but when i choose a relatively big resolution it make texture blurry and very big as compare to screen size.

please guide me, need help :(

avatar image meat5000 ♦ · Feb 07, 2014 at 01:13 PM 0
Share

$$anonymous$$eep all GUITexture entries as default. Place the GUITexture on an object and use the objects transform to position and size the texture. Works independently of res.

Show more comments
avatar image
-1

Answer by alok-kr-029 · Sep 24, 2013 at 05:02 AM

Make a plane attach your texture and make it child of ur camera ta da it will work.....

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
0

Answer by bernardfrancois · Jan 20, 2013 at 09:58 PM

You may want to use the GUI system instead, by simply calling this in the OnGUI method:

 GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), texture);
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
0

Answer by niknar · Jan 21, 2013 at 04:34 AM

I do it this way when I use GUITextures for menu backgrounds

public GUITexture MenuBG1; MenuBG1.pixelInset = new Rect(0,0,Screen.width,Screen.height);

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 Eric5h5 · Jan 21, 2013 at 05:50 AM 0
Share

That doesn't work so well because you have to check for resolution changes and run the code again if the resolution changes (e.g., player resizes window). Just do what I said and set the x/y scale to 1, then it's always correct with no code.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 People are following this question.

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

Related Questions

How to maintain high resolution custom background images for GUI elements on different screen sizes? 0 Answers

Asset Variations for Different Mobile Screen Sizes 1 Answer

Player Screen Resolution 2 Answers

GUI Positioning Problems 1 Answer

How do you auto scale the space between Gui Buttons? 1 Answer


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