• 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 nooberific · Feb 28, 2012 at 06:18 PM · guiprogramminggui.label

Multiple GUI.Labels to appear and disappear

How to I make multiple GUI.Labels appear and disappear to have another GUI.Label take it's place without using coroutines?

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
0

Answer by Kona · Feb 28, 2012 at 07:22 PM

I suppose you could use boolean values or if you have many different states make an enum, then in the method from where you're creating those labels you do something like

if( myBool ) GUI.Label(new Rect( 5, 5, 50, 50 ), "Label 1 : True!" );

else GUI.Label(new Rect( 50, 50, 50, 50 ), "Label 2 : False!" );

or if you just want the text to change and not make entirely new labels you could just define a string and make the label display that string, and depending on the state you change the string.

bool myBool = true; string myString = "The String"

GUI.Label( new Rect( 5, 5, 50, 50 ), myString );

if( myBool ) myString = "True"; else myString = "False";

And as said if you have several states that should affect the label(s) you could set up a switch case:)

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Multiple Cars not working 1 Answer

hide gui.label after an event 1 Answer

Hide GUI Label behind an object? 3 Answers

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

Cropped Label Problem - Big Font - Unity3D 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges