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
2
Question by Tobias · Jun 08, 2010 at 06:12 PM · guilabel

GUI Destroy Label?

Hi, is it possible to destroy a GUI.Label?

Ive tried to put the Gui.label in an variable but theres no variable type GUILabel.

and when I use var test = GUI.Label(...) it gives me the error (Cannot convert void to void).

Thanks

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

3 Replies

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

Answer by Eric5h5 · Jun 08, 2010 at 06:31 PM

Simply use a boolean so you don't run the GUI.Label code when you don't need it:

if (showLabel) {
    GUI.Label(someRect, "Blah");
}
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 Tobias · Jun 08, 2010 at 06:39 PM 0
Share

Thanks but in my case it will not work, because I need to recreate the label with another text, and I cant swap the text while GUI.Label is allready created

avatar image Eric5h5 · Jun 08, 2010 at 07:20 PM 1
Share

@Tobias: I don't really understand what you just said. ;) There's nothing in the code I wrote that would prevent you from using any other text, or swapping it with whatever you like. Just replace "Blah" with a string variable. GUI.Labels aren't objects that are just created once, they are re-drawn every frame (sometimes several times per frame).

avatar image
1

Answer by Tetrad · Jun 08, 2010 at 06:48 PM

You can't think of GUI.Label as creating a type. It's probably more accurate to think of it as telling Unity's GUI system to print that label with whatever you pass into it every frame.

So if you need it to change, store off a string to what you want to print, and tell the GUI.Label to print that string instead of hard-coding a particular string.

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 BigJac09 · Aug 31, 2011 at 09:02 PM

I got the same problem, my strings was in an array. The value I use was a class member and it always showed the string in position 1. I printed the value used in OnGUI to acces my array and it passed from the right value back to 1. I discovered that it went in fact back to the first nonzero number I initialized my int to.

I solve my problem by setting the member static.

If someone could as an idea as to what was happening...

Hope it helps someone.

Cheers

Edit : Turns out I had set my script to an object it was not suppose to so I really did have two Label on my screen...

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.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

GUI Scripting button controls 1 Answer

How to make a GUI Label always in the center 1 Answer

Setting Scroll View Width GUILayout 1 Answer

Show enum in a loop in on GUI 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