• 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
Question by Benjam · Apr 27, 2013 at 05:19 PM · guitextlabeloverlapping

GUI.label overlapping text

Hello,

I am having a problem with my GUI.Label. I am trying to get it to display variables in my code for debugging etc. but when the variable changes it overlaps with the previous and i end up with a mess (see screenshot)

alt text

I have looked for solutions online but not found something solid enough to fix this problem. Has anyone ever come across this. Here is my GUI function, as short as it is.

     void OnGUI()
     {
         
         GUI.Label(new Rect(15, 15, 150, 30), "isJump = " + leftThumbValueX);
     }
overlapping gui.jpg (22.1 kB)
Comment

People who like this

0 Show 6
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 ExTheSea · Apr 27, 2013 at 07:02 PM 2
Share

Is it possible that you maybe have a second label which gets displayed at the same location? I never saw a case where a single label can overlap. There has to be a second label displaying something like: "isJump = " + anotherValue or something like this.

avatar image Benjam · Apr 28, 2013 at 11:51 AM 0
Share

No this is the only instance of this function in my script there is also no other version of this function in any of my other scripts. I can't get my head around it :\

avatar image ExTheSea · Apr 28, 2013 at 11:55 AM 0
Share

Are there maybe two instances of this script active at the same time. ...maybe attached to different gameobjects?

avatar image Benjam · Apr 28, 2013 at 12:06 PM 0
Share

Hmm, so I removed my movement script from my character and the GUI ran perfectly well....Is there something I am missing when using OnGUI? To test this out i put OnGUI in a separate script and assigned it to my character, it worked well except it ruined the controls....

avatar image Benjam · Apr 28, 2013 at 12:17 PM 0
Share

I have attached the movement function to a main object in the scene that is a parent of a few other bits and pieces....could this be why its overlapping?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by whydoidoit · Apr 28, 2013 at 01:23 PM

If you Subclass a script then clearly those scripts OnGUI will also be called, calling through to the base. Answer - avoid using inheritance in your game logic if you can - it leads to problems like this - try to use a component/composition architecture. If you use inheritance then expect the base class functions to be called.

If you want to hide the underlying scripts OnGUI in a subclass then just do:

 void OnGUI() {} 

In the subclass.

Comment
ExTheSea

People who like this

1 Show 0 · 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

14 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

Related Questions

Custom Console in Application 1 Answer

Ngui Text Vertical Scrollbar? 1 Answer

Changing the size of a GUI label 1 Answer

Can't draw GUI.Label text on subpixel values 0 Answers

GUI label/text appear/disappear 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