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 t-pedrob · Mar 06, 2015 at 01:06 PM · databasedatadata storagesqlquiz

[Quiz game] How do I make players contribute with questions?

Hello guys, I'm doing a quiz game but I want to make players contribute to the game with questions. Any ideas of an easy and practical way of doing it?

Where and how to store and retrieve new questions?

Comment
Add comment · Show 2
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 fafase · Mar 06, 2015 at 01:41 PM 0
Share

Create a basic form with GUI where you have one field for the question, then let's say 4 field for the answer and a tick box defining the correct answer (you can use toggle for that or a simply integer field).

Have a send button that will parse the form into a json file that you send into a WWWForm.

Then your game will collect all the json forms that are found on the server and propose them.

Obviously, this sounds like a very vague answer but well, this question was not so precise and what, how and what you can do.

avatar image t-pedrob · Mar 06, 2015 at 02:36 PM 0
Share

Hi, thanks for replying. You figured it out really quickly what my problem was. I'm new in this kind of stuff, so do you know any unity example able of parsing a form into a json file and send that into a wwwform and them SQL?

Thanks again :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Cherno · Mar 06, 2015 at 01:37 PM

I would do it like this:

Crate a new class "Question":

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 [System.Serializable]
 public class Question {
 
     public string questionText = "What currency does the United States use as of 2015?";
         public List<string> answers = new List<string>() {"Dollar", "U.S. Dollar", "USD", "US Dollar"};
 
 
 }


I use a list for the answer string so more than one answer can be correct if I wish.

Then, create a questionaire: Simply a list of the Question class:

 public List<Question> questionaire = new List<Question>();

Now you can let players Add questions simply by adding to the list and filling in the values for questionText and answers.

To draw a random question:

 string newQuestion = questionaire[Random.Range(0, questionaire.Count - 1)];
 
 string questionTextCur = newQuestion.questionText;
 
 

To check if an answer is correct:

 string answerText = "Euro";
 
 if(newQuestion.answers.Contains(answerText)) {
      Debug.Log("Right answer!");
 }
 else {
      Debug.Log("Wrong answer!");
 }


If by storing and retrieving you mean actually saving and loading to/from file, then look into Serialization and BinaryFormatters.

Comment
Add comment · Show 3 · 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 t-pedrob · Mar 06, 2015 at 02:42 PM 0
Share

Hello, Thanks for you example it works well locally but my problem is not how to do it locally but how to get a new question created and send it to a server. Those new questions on the server will be retrived to other players game.

Any example of how to do this.

Thanks for your time.

avatar image Cherno · Mar 06, 2015 at 03:09 PM 0
Share

Well, that kind of info would have been nice in the original question, wouldn't it? :) Unfortunately I have no experience with server-client communicatino.

avatar image t-pedrob · Mar 06, 2015 at 05:27 PM 0
Share

Thanks for your time

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

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

Why PlayerPrefs not working although I use "HasKey" and Save() on android? 0 Answers

Linq Query - Strange Outcome 1 Answer

Storing data on a server to be used for player currency in a multiplayer game 1 Answer

How do I go about using a server to store and retrieve data? 0 Answers

How do I go about using a server to store and retrieve data? 0 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