• 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 CornDog3241 · May 28, 2012 at 09:52 PM · guibuttons

GUI Display

Hey everyone, I'm currently working on a game for a class I have and I need just a little bit of help.

This is what the code looks like...

 var Cactus : Texture2D;
 var Cactus2 : Texture2D;
 var button1clicked=false;
 
 function OnGUI () {
     if (GUI.Button (Rect (375, 100, 150, 100), Cactus)) {
         if(!button1clicked)
             button1clicked=true;
         else
             button1clicked=false;
     }
     
     if(button1clicked){
         GUI.Box(Rect(375, 210, 315, 300), "");
         GUI.Label(Rect(375, 210, 90, 90),"Cactus");
         GUI.Box(Rect(10, 370, 350, 140), Cactus2);
     }    
 }

What I want to happen is when I click another button, the previous button is deactivated.

Does anyone know what the code would look like? All the help would be greatly appreciated! :D

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 bodec · May 28, 2012 at 10:54 PM

you will need something like

if(button){ button2 = false }

and a second one for the other way or wrap it in a case statment.

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

GUI Display Help 0 Answers

Stuck with sliding GUI panels 0 Answers

Problem with rect and touch 1 Answer

Bringing window to back GUI.BringWindowToBack() 0 Answers

GUI.Button flipped not working 1 Answer

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