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
0
Question by lottielottie · Mar 04, 2013 at 11:11 PM · buttonsonguiinterfacetextbox

Help much appreciated with buttons and text fields please

Hi, This is the 1st time I have asked a question so I apologise now if its not done properly.

I am very new to Unity and I'm struggling with creating some buttons on my interface.

I have the buttons, they work when pressed - the text appears where it should, but then when the next button is clicked it just pastes the new text over the top of the other. It does this for all 6 buttons. My question is how do I get the text to disappear when another button is pressed? I don't mind the text being there until another button is clicked, just don't want it pasting it on top of each other.

I also apologise if my script is not very good, I know there must be a shorter way of writing what I have already.

Thanks in advance.

  var submitPressed = false;
  var msgtxt = "This info will be about the Colosseum from 60-72AD";
  var submitPressed2 = false;
  var msgtxt2 = "This info will be about the Colosseum from 72-90AD";
  var submitPressed3 = false;
  var msgtxt3 = "This info will be about the games at the Colosseum";
  var submitPressed4 = false;
  var msgtxt4 = "This info will be about the gladiators";
  var submitPressed5 = false;
  var msgtxt5 = "This info will be about the construction of the Colosseum";
  var submitPressed6 = false;
  var msgtxt6 = "This info will be about the Emperors"; 
  
  function OnGUI() {
 
 GUI.skin = MenuSkin;
 
     GUI.BeginGroup(new Rect(Screen.width/2-600,Screen.height/2-350,700,700));
 
         GUI.Box(Rect(0,0,300,700),"The Roman Colosseum");
 
             GUI.Button(Rect(10,30,130,50),"Fly Through One");
             GUI.Button(Rect(160,30,130,50),"Fly Through Two");
             
             
             
             
         if( GUI.Button(Rect(10,90,130,50),"60AD - 72AD")){
             submitPressed = true;
             }
         if( submitPressed ) {
             GUI.Box(Rect(10,270,280,420),msgtxt );
             }
         
            if( GUI.Button(Rect(160,90,130,50),"72AD - 90AD")){
             submitPressed2 = true;
             }
         if( submitPressed2 ) {
             GUI.Box(Rect(10,270,280,420),msgtxt2 );
             }
             
         if( GUI.Button(Rect(10,150,130,50),"The Games")){
             submitPressed3 = true;
             }
         if( submitPressed3 ) {
             GUI.Box(Rect(10,270,280,420),msgtxt3 );
             }
             
         if( GUI.Button(Rect(160,150,130,50),"Gladiators")){
             submitPressed4 = true;
             }
         if( submitPressed4 ) {
             GUI.Box(Rect(10,270,280,420),msgtxt4 );
             }
             
          if( GUI.Button(Rect(160,210,130,50),"Emperors")){
             submitPressed5 = true;
             }
         if( submitPressed5 ) {
             GUI.Box(Rect(10,270,280,420),msgtxt5 );
             }
             
         if( GUI.Button(Rect(10,210,130,50),"Construction")){
             submitPressed6 = true;
             }
         if( submitPressed6 ) {
             GUI.Box(Rect(10,270,280,420),msgtxt6 );
             }
             
    GUI.EndGroup ();
    
 } 
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

0 Replies

· Add your reply
  • Sort: 

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

10 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

Related Questions

How do I delay the appearance of these buttons? 3 Answers

OnGUI elements in editor scene view 1 Answer

UI Buttons dont react on click 4 Answers

How to make this text box disappear after a set amount of time? 1 Answer

text box and button won't display 2 Answers


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