• 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 joeybbb · Dec 30, 2011 at 12:00 AM · guiscreenguitexturehudfull

Make my HUD full screen

Hello the title says it all. I have a GUITexture and it is transparent in the middle i am using as a HUD. It works fine, but is too small and also, if i build the game and run it on different PC with a different screen size, how can i auto adjust it to fit the screen. Please help, it is greatly appreciated :)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by macweirdo · Dec 30, 2011 at 01:16 AM

You can use Screen.width and Screen.height to find the screen width and height.

And a PROTIP: Instead of defining controls in a hardcoded way like Rect(10,10,50,50) try the fluidly changeable Rect(screen.width*0.01,screen.height*0.01,screen.width*0.05,screen.height*0.05)

or even the GUILayout class (look in the script reference in [Menu]->[Help]->[Scripting Reference].

Comment
Add comment · Show 8 · 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 joeybbb · Dec 30, 2011 at 02:45 AM 0
Share

But where do I edit the size of the GUI Texture? There is only pixel inset, which is location on screen, not size.

avatar image joeybbb · Dec 30, 2011 at 11:08 AM 0
Share

Sorry, what I meant was: the height and width values dont let me type in letters, only numbers, so how do I type in screen.width etc???

avatar image macweirdo · Dec 30, 2011 at 03:13 PM 0
Share

You do this via scripting so:

function OnGUI () { //stuff here }

avatar image joeybbb · Jan 01, 2012 at 03:17 AM 0
Share

Ok thanx. So I havent done any GUI Scripting before do I need to attach the finished script to the GUI Texture or anything in the scene

avatar image macweirdo · Jan 01, 2012 at 02:53 PM 0
Share

Attach the finished script on any object in the scene. Just remember which one it was.

Show more comments
avatar image
0

Answer by CursedScripter · Dec 30, 2011 at 12:17 AM

Lets say you position it at the center of a smaller screen. You set the x position as 550 and the y as 550. This is a better solution. Screen.width / 2 for the x and Screen.height / 2 for the y. You might want it a little altered depending on what you use it for. (Screen.width / 2) - 50 for x or something like that.

Hope it helps

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

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

6 People are following this question.

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

Related Questions

Best approach to define interactive screen areas regardless of it's resolution? 3 Answers

How do I scale a GUITexture from the sides instead of in the center? 1 Answer

how to rotate GUI Textures 5 Answers

GUITexture scaling with aspect ratio? 1 Answer

Aligning an overlay to existing GUI elements 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