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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by leke · Jan 21, 2014 at 07:02 PM · labelquiz

How to turn a label off as the next button is pressed in a Quiz game

pls help!i'm trying to create a quiz game and i have modified a script to have a background window and a question would come up each time the user presses next question but my challenge now is the previous questions (in form of labels)refuse to disappear as the next question comes up i.e they are all one the same window which i dont want. i want the previous questions to disappear as the user presses the "next button". Pls any hlp wud b greatly appreciated. you can modify and even suggest new codes that i can use. tanx in advance. This is my code

  #pragma strict
 var gameMessageFont : Font;
 var isBoxShowing : boolean = false;
 var isBox2Showing : boolean = false;
 var isBox3Showing : boolean = false;
  function OnGUI() {
 GUI.skin.font = gameMessageFont;
 GUI.Box(Rect(0, 0, 850, 290), "Exam");
 if (!isBoxShowing && GUI.Button(Rect(360, 250, 150, 30), "Next Question")) {
 isBox2Showing = true;
 }
 if(isBox2Showing) {
 GUI.Label(Rect(0, 0, 850, 290), "Question 2");
 if (!isBoxShowing && isBox2Showing && GUI.Button(Rect(160, 250, 150, 30), "To Question 3")) {

isBox3Showing = true; } } if(isBox3Showing) { GUI.Label(Rect(100, 0, 850, 290), "Question 3"); if (!isBoxShowing && isBox2Showing && isBox3Showing && GUI.Button(Rect(560, 250, 150, 30), "To Question 4")) { } } }

Comment
Add comment · Show 1
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 dscroggi · Jan 22, 2014 at 12:35 AM 0
Share

If the labels are all in the same place could store the question in a variable and just change that?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dscroggi · Jan 22, 2014 at 12:45 AM

Something like this maybe?

 var gameMessageFont : Font;
 var current : int = 0;
 var questions : String[];
 
 function Start ()
 {
     GUI.skin.font = gameMessageFont;
     
     questions = ["Question 1", "Question 2"];
 }
 
 function OnGUI () 
 {
     GUI.Label(Rect(0, 0, 850, 290), questions[current]);
     
     if(GUI.Button(Rect(160, 250, 150, 30), "To Question " + current.ToString())) 
     {
         current = current++ % questions.Length;
     }
 }
Comment
Add comment · Show 1 · 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 leke · Jan 22, 2014 at 01:50 PM 0
Share

tanx for d reply i appreciate it, but ur code is not doin anytin when the "to question 1" button is pressed. i want a quiz kinda game whr different questions in different windows can be seen. for example, question 1 is in one window and when i press the "next question" button another window with question 2 pops up while the previous question (question 1) disappears.and if i press the "next question" button, question 3 pops up in another window while question 2 disappears and so on till question 10. pls help me out here.... tanx in advance.

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

19 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Changing Button/Label text size? 2 Answers

Displaying Level 1 Answer

Where are asset labels stored? 1 Answer

GUI.Label appers bad when font size is too big 3 Answers

how to make global labels in front and GUI.BringWindowToBack(ID); 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