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 FlowerCraft · Jul 25, 2012 at 04:07 AM · resolutionscreenheightwidth

Screen width and height, how to bypass?!

There's so many questions on this, and not really any useful answers. Using Screen.height seems so bugged, I'm trying to place something in lower left corner, so I put in the y coordinate as screen height minus the height of the button, and it places it somewhat right, now, if I build and change resolution, all of a sudden the button is halfway up the window, and even worse on higher resulotions. How do you work with this?!

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

1 Reply

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

Answer by Eric5h5 · Jul 25, 2012 at 04:12 AM

There's nothing bugged about it. You don't need to bypass it, you just need to use it correctly. I assume you're doing something like storing the screen height instead of using it dynamically.

 function OnGUI () {
  GUI.Label (Rect(0, Screen.height-20, 100, 20), "Works fine");
 }
Comment
Add comment · Show 7 · 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 FlowerCraft · Jul 25, 2012 at 12:44 PM 0
Share

Tell me, if I use a setup where I have the variable of the window rect like

var window = Rect (Screen.height-300,25, 350, 300);

and then calls it from on gui like

Window = GUI.Window (11, Window, WindowSettings, " ");

This does not update the placement, this sets it as it is in when I put the script on, then stays in that position even when I change resolution on startup?

avatar image Eric5h5 · Jul 25, 2012 at 04:03 PM 0
Share

You can't use Screen.height for the x value. (Well, you can, but it's totally wrong.)

avatar image perchik · Jul 25, 2012 at 04:31 PM 0
Share

Your example doesn't update the placement because I'm assu$$anonymous$$g you only set that variable once (perhaps on start?) If you set that variable on Update it should change when you change the resolution.

But Eric is right, you've got the x-coordinate set as relative to Height, so it's probably not going to give you expected results

avatar image FlowerCraft · Jul 26, 2012 at 12:02 AM 0
Share

X as relative height? I don't think so? I've got 0,height, I'm assu$$anonymous$$g x,y, so that means i've got height as y, not x. Anyway, what Perchick said might make sense, that it's fixed, and not in the update. But how do I update it, when I've made it like I have.

avatar image FlowerCraft · Jul 26, 2012 at 12:04 AM 0
Share

var HUD_LoginWindow = Rect (25,25,260,140);

function OnGUI () { HUD_LoginWindow = GUI.Window (1, HUD_LoginWindow, HUD_LoginSettings, ""); }

function HUD_LoginSettings() { }

Show more comments

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

7 People are following this question.

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

Related Questions

How can I make the game Screen to fit resolution 2 Answers

Object resolution 0 Answers

Game fills only one quarter of the screen, why? (Android) 1 Answer

Keep screen width instead of height for resolutions 1 Answer

Is it better to enlarge an image by width/height or by scale? 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