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 question was closed Jan 29, 2014 at 05:54 PM by AlucardJay for the following reason:

Other : Asking for Scripts

avatar image
-1
Question by Uping · Jan 27, 2014 at 12:57 AM · gamemultiplequizpop-up

Creating a Multiple Choice Game

im creating a game that will make a multiple choice question will pop up while playing but i dont have and idea on how to do it may because im really new at coding and im really dumb at it but im willing to learn so please help me and give me an example code/script for what i want to do and i promise that i will study it by the way this is for my thesis project and i really need to finish it to graduate so advance thanks for anyone who's willing to help me i just nid a sample code because i dont know how to do it from scratch thankyou

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

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by KellyThomas · Jan 27, 2014 at 01:12 AM

No one will want to do your homework for you but people will probably offer some advice and guidance along the way.

The first thing to do is break down a project into a series of manageable tasks. You can then focus on building a each small part, and slowly expand until you have built the whole.

  1. A multiple choice game is really a series of individual questions (with a running tally for score).

  2. Each question takes the form of a passage of text (the question) and several other passages of text (the answers) for the player to choose from.

I would recommend using Unity's GUI tools to implement this, the question could be a label and each answer could be a button.

I think you will find everything you need to know to implement an individual question over here in the documentation.

First build the code to:

  1. Display the question

  2. then the buttons

  3. determine if the answer was correct

Once you have that up and running please come back here and ask more focused questions if/when you encounter specific problems.

Comment
Add comment · Show 14 · 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 Uping · Jan 28, 2014 at 09:38 PM 0
Share

thank you sir.

avatar image Uping · Jan 29, 2014 at 09:50 AM 0
Share

Sir i code a script where in when you press the button a label with another button will appear but what happens is when you click the object where you put the script thats where it pop up so i want it to pop up in when you press the button and not the object please help me again thank you using UnityEngine; using System.Collections; public class Attack : $$anonymous$$onoBehaviour { // Use this for initialization private bool Poop; public string Info; void On$$anonymous$$ouseDown() { Poop = true; } void DrawInfo() { Rect rect = new Rect (600,500, 200, 100); Rect close = new Rect (10,20,200,200); if (Poop) { GUI.Box(rect, Info); if (GUI.Button(close,"X")) { Poop = false; } } } void OnGUI() { DrawInfo(); } }

avatar image KellyThomas · Jan 29, 2014 at 11:50 AM 1
Share

Well the On$$anonymous$$ouseDown() method is intended to behave like that, it may not meet your needs.

You could try this implementation, it has a couple of changes so that:

  1. the close button is always drawn

  2. the close button now toggles the Box's visibility on and off.

.

 void DrawInfo() {
     Rect rect = new Rect (600,500, 200, 100);
     Rect close = new Rect (10,20,200,200);

     if (GUI.Button(close,"X")) {
         Poop = !Poop;
     }

     if (Poop) {
         GUI.Box(rect, Info);
     }
 }
avatar image Uping · Jan 29, 2014 at 01:55 PM 0
Share

thanks bro you really solved my problem anyway i already did two of the things you told me

1.Display the question 2.then the buttons

can you help me for another problem, how can i randomize the question that will be show'n every time that i push the button here's the code that ive done anyway thanks a lot for your help

 using UnityEngine;
 using System.Collections;
 
 public class wawa : $$anonymous$$onoBehaviour {
 
 // Use this for initialization
 private bool Poop;
 public string Info;
  
 void On$$anonymous$$ouseDown()
 {
     Poop = true;
 }
  
 void DrawInfo()
 {
     Rect rect = new Rect (500,100, 400,200);
     Rect close = new Rect (600,500,200,100);
     if (GUI.Button(close,"ATTAC$$anonymous$$")) {
         Poop = !Poop;
     }
  
     if (Poop) {
         GUI.Box(rect, Info);
         GUI.Label(new Rect (520, 110, 400, 30), "QUESTION");
         GUI.Button (new Rect (520, 200, 100, 30), "A");
         GUI.Button (new Rect (520, 250, 100, 30), "B");
         GUI.Button (new Rect (780, 200, 100, 30), "C");
         GUI.Button (new Rect (780, 250, 100, 30), "D");
         //GUI.Label (Rect (0,0,100,50), "This is the text string for a Label Control");
             
         }
 }
  
 void OnGUI()
 {
  
     DrawInfo();
 }
 }
 
avatar image KellyThomas · Jan 29, 2014 at 02:50 PM 0
Share

The best approach depends a little bit on how you want things laid out.

Do you want it with the answers included in the question string, so it looks like this:

 What in the Capital of France:
 A) Paris
 B) New York
 C) London
 D) $$anonymous$$adrid

 [ A ]                   [ B ]
 [ C ]                   [ D ]


You do you want the answers on the buttons, so it looks like this:

 What in the Capital of France?

 [ Paris ]        [ New York ]
 [ London ]         [ $$anonymous$$adrid ]


Do you want the questions written in your code? or loaded from a text file?

The first layout and the question written in the code are the easiest to get working but it's best to clarify requirements up front.

Show more comments
avatar image
1

Answer by gogott · Jan 27, 2014 at 01:24 AM

The simplest thing is to use the GUI to ask the question and get the answer: link text

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 Uping · Jan 28, 2014 at 09:38 PM 0
Share

thanks for the advice :)

Follow this Question

Answers Answers and Comments

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

Related Questions

Multiple Choice game in Unity 0 Answers

Best way to make a Quiz system? 0 Answers

Make quiz game Confused About PlayerPrefs and database 1 Answer

Instantiate a 2d Pop up 1 Answer

What does Mecanim DO? 3 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