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
1
Question by ngs6_16 · Jun 12, 2012 at 06:53 PM · guipositionlabeloverlap

GUI Labels Overlap

I am trying to have gui labels display various statistical elements. I seem to be missing something about changing the position of these, most of them are overlapping and their position will not change. And when I was changing the position on the first ones, I had to restart Unity to see some of the updates.

Here is the scripts (the important part anyway)

     var labelPos1 : Rect =  Rect(10,16,100,20);
 var labelPos2 : Rect =  Rect(10,32,100,40);
 var labelPos3 : Rect =  Rect(100,16,200,20);
 var labelPos4 : Rect =  Rect(100,32,200,40);
 var labelPos5 : Rect =  Rect(10,48,100,20);
 var labelPos6 : Rect =  Rect(10,64,100,40);
 var labelPos7 : Rect =  Rect(200,48,300,20);
 var labelPos8 : Rect =  Rect(200,64,300,40);
 
     
 function OnGUI()
 {
          GUI.Label(labelPos1, "Strength:" + strength);
          GUI.Label(labelPos2, "Dexterity:" + dexterity); 
          GUI.Label(labelPos3, "Health:" + healthCurrent);
          GUI.Label(labelPos4, "Stamina:" + staminaCurrent); 
          GUI.Label(labelPos5, "S:" + strength);
          GUI.Label(labelPos6, "D:" + dexterity); 
          GUI.Label(labelPos7, "H:" + healthCurrent);
          GUI.Label(labelPos8, "S:" + staminaCurrent); 
 }
Comment
Add comment · Show 1
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 Berenger · Jun 12, 2012 at 07:25 PM 0
Share

This code seems alright. Could you upload a screenshot ?

2 Replies

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

Answer by ngs6_16 · Jun 13, 2012 at 02:46 PM

I figured it out literally 2 minutes after I posted the question.

The problem was for some reason I needed to make the variables private.

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 hathol · Jun 12, 2012 at 07:36 PM

Not sure about the problem with them not changing position, since the function is fine. However, the overlapping is easily explained:

The rect is defined as (x,y,width,height). So if your first label is at y=16 and has a height of 20, its lower bounds extend to y=36. Since your label 2 starts at y=32 it's overlapping 4 pixels. Similar for the rest of your labels.

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 Berenger · Jun 12, 2012 at 07:49 PM 0
Share

But unless he is using a skin, the label doesn't have a background so the overlapping would be visible only if the letters overlaps

avatar image ngs6_16 · Jun 13, 2012 at 01:01 PM 0
Share

Thats not the problem I was having. But i did need to know the exact details on what the x,y,width,height was so thank you very much for that! I did figure it out though. I needed the variables to be private for some reason... maybe something to do with pragma strict.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI Label Size and Position Changes With Resolution 2 Answers

Trying to draw GUI.Label() at object position 5 Answers

How do I position a GUI Label over an object? 1 Answer

Auto positioning GUI Labels? 0 Answers

Gui label variable as a string.. 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