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 kiwiboys · Feb 26, 2014 at 12:31 AM · gui

GUI always changes Position with different resolutions.

Hello im not to sure if this has been answered before i have looked trust me from watching youtube tutorials to searching forms even look for assets store for help.

the problem is that when the player dies i need a death screen to appear it works in full screen mode but nothing else not even in the test build. i write in c# and a lot of answers are in unityscript / javascript

heres what i got

 {
         if (dead == true){
             GUI.Box (new Rect (860,200,300,500), "Level Failed");{
                 // restart button
                 if(GUI.Button(new Rect(930,270,100,20), "Restart Level")) {
                     reboot();
                 }
             //exit button
                 {if(GUI.Button(new Rect(930,370,100,20), "Quit Game")) {
                         Application.Quit();
             
                     }
             }
         }
     }
 
 
       }

i know it poorly formatted but i want to get it working at least then clean it up later. Any help would be much 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 AndyMartin458 · Feb 26, 2014 at 12:36 AM

You should be doing your rectangle coordinate calculations based on Screen.width and Screen.height. You should also do this for your other types of GUI objects, but I showed you the box as an example.

 //Try doing these calcualtions of the width and height to fit your box within the screen
 GUI.Box (new Rect (0, Screen.width / 5f, 0, Screen.height / 5f), "Level Failed");
Comment
Add comment · Show 5 · 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 kiwiboys · Feb 26, 2014 at 01:51 AM 0
Share

how would i go about finding the width and height ,when i tried the code the box wasn't on the screen at all. or is it that i need to set the size of the box?

avatar image GambinoInd · Feb 26, 2014 at 06:09 AM 0
Share

Try something like, GUI.Button(new Rect(Screen.width/5f,Screen.height/5f,100,20)

avatar image kiwiboys · Feb 26, 2014 at 07:37 AM 0
Share

ok so i have the box not moving no matter the size i tried to to this with the buttons but no successes the still move around here is the box code

GUI.Box(new Rect(Screen.width/2.4f,Screen.height/3.3f,500,200), "Level Failed");{

and the button code

if( GUI.Button(new Rect(Screen.width/2f,Screen.height/2.9f,200,20), "restart level")) {

any ideas why this is happening?

avatar image AndyMartin458 · Mar 10, 2014 at 10:35 PM 0
Share

@kiwiboys the buttons should behave the exact same way. The one thing that might not be working is the hardcoding of the width and height of the button. If you want to it to start at 1/2.4 of the screen width, try making the total width something like Screen.Width/ 5 ins$$anonymous$$d of 500.

avatar image kiwiboys · Mar 11, 2014 at 07:43 PM 0
Share

hmm i will give this a go. but because this game is intended to run on multiple platforms and resolutions i may need to look into other ways of achieve it

avatar image
0

Answer by zharik86 · Feb 26, 2014 at 07:13 AM

Maybe, you need use GUI.matrix. See my pregoing answer1 or answer2.

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 kiwiboys · Feb 26, 2014 at 08:07 AM 0
Share

would NGUI work its at the assets store? Because I need to change it to a picture later and I don't think matrixs work with that texture.

avatar image zharik86 · Feb 26, 2014 at 07:15 PM 0
Share

@kiwiboys I, unfortunately, didn't work with NGUI. Generally I work with GUI from Unity. But it is sure that for NGUI scaling for different resolution of screen shall be provided.

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

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

get the mouse cursor position x and y and make gui follow on trigger -1 Answers

c# - void method from external class. 2 Answers

Efficient GUI resizing 0 Answers

Styling an individual button in SelectionGrid 0 Answers

Neutral state for toggle buttons? 2 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