UGTK / Toolkit / Gameplay Systems / Quiz System Completed
Quiz System
Summary
A data-driven quiz minigame: quizzes and questions are authored in SO_LinearQuiz / SO_GridQuiz ScriptableObjects (importable/exportable as CSV/JSON), one database per language. A manager picks the localized database, a controller builds and sequences questions, and a UI manager shows answer groups and colored correct/wrong feedback, tallying points to a win/lose result.
Content
Modules Dependencies
- Data / DictionarySystem (
UGTK.Data.DictionarySystem):S_Dictionary/BiTypefor the per-language database map and the answer-count → UI map. - GameplaySystems / LanguageSystem (
UGTK.GameplaySystems.LanguageSystem):Mn_LanguageManagersupplies language ids and the current language. - UIModule / SliderSystem (
UGTK.UIModule.SliderSystem):Mn_SliderControllerdrives the question-progress slider. - DesignPattern / Singleton (
UGTK.DesignPattern.Singleton):Mn_QuizUiManageris anMn_Singleton. - UnityGamesToolkit.Runtime: list helpers
RandomElement()/Shuffle().
Carried inside the prefabs. These modules are not referenced by the assembly definition - the components are simply already attached to the prefabs this module ships. Remove one of them from the project and the prefab keeps its layout and loses that behaviour, with nothing in the console to say so.
| Module | Component, and the prefab carrying it |
|---|---|
UIModule/TextUpdaterSystem |
Mn_TextUpdater (in SingleAnswer) |
Setup
The questions live in an asset, not in the scene.
- Create a quiz database:
SO_LinearQuizfor a fixed run of questions, orSO_GridQuizwhen the questions form a board (categories across, difficulty down). - Fill it in the inspector, or import a CSV -
QuizTemplate_Example.csvinDebug/is the shape the importer expects. - Add the
QuizManagerprefab and give it the database.Mn_QuizManagerruns the quiz;Mn_QuizControllerdrives one question;Mn_QuizUiManageris aMn_Singletonholding the screens. - Choose the answer layout:
QuizGroup2throughQuizGroup6are ready-made for two to six answers, withSingleAnsweras the button they clone andQuestionas the question row.
Check the CSV import against a question containing a comma before trusting it, and quote the field the way the template does. A quiz whose questions are ordinary prose will contain commas on the first day, and an importer that splits naively shifts every later column without ever failing.
If the game is multilingual, the LanguageSystem picks the database per language through a generated
S_Dictionary - one quiz asset per language, selected for you.
How To Use
- Author data: create an
SO_LinearQuiz(orSO_GridQuiz) asset holding quizzes; each quiz has a list ofS_Question(question text, one correct answer, wrong answers, points, position/randomization flags). Data can be imported/exported via the CSV and JSON utilities (QuizCsvUtility,QuizJsonUtility,QuizExportEditorUtility). - Scene setup: place the provided prefabs —
QuizManager,QuizController,QuizUiManager, aQuestion,SingleAnswerand theQuizGroupNanswer-layout groups (2–6 answers). - Localized databases: on
Mn_QuizManager, thelocalizedQuizDatabasesdictionary auto-generates one slot per language declared inMn_LanguageManager(keys are code-generated, do not edit by hand); assign anSO_LinearQuizper language. A legacy single-database field is migrated automatically. - Start a quiz: call
StartWithFirstQuiz(),StartWithRandomQuiz(), orStartWithIDQuiz(id)(or enablestartWithFirstQuizOnStart). The manager resolves the database for the current language (falling back to the first assigned one). - Flow:
Mn_QuizController.Initclones the quiz (optionally trimming to a fixed count or a random range of questions), thenPrepareNewQuestionbuilds eachMn_Questionand asksMn_QuizUiManagerto show the matchingQuizGroupNUI. Clicking anMn_AnswercallsAnswerToQuestion, firingonAnsweredCorrectly/onAnsweredBadly; the UI manager flashes the answer color forfeedbackTimeseconds (optionally revealing the correct one) and then auto-advances. - End: when questions run out the controller invokes
onEndedQuiz;Mn_QuizManager.EndQuizcompares gained points tominimumPointsForWinand firesonWinoronLose.
Testing Scene
Open QuizSceneExample in the module's Debug/ folder.
What to do, in order:
- Play a full quiz to the end and check the score.
- Answer wrongly on purpose and see what the feedback says.
- Let a timed question run out without answering.
- Import a CSV whose question text contains a comma, and a quoted field.
Step 4 is the one that breaks naive implementations: a question containing a comma is completely ordinary, and a parser that simply splits on the separator corrupts the whole row. Step 3 is the state players reach constantly and developers rarely test.
QuizSceneExample running the four sample riddles: the counter advances, the score updates,
and the answer positions are shuffled between questions because answersRandomPosition is on.
Technical Info
- Mn_QuizManager: owns the per-language
S_Dictionary<string, SO_LinearQuiz>, syncs it withMn_LanguageManager(SyncLanguagesWithManager), resolvesGetCurrentDatabase(), starts quizzes (first/random/by-id) and evaluates win/lose inEndQuiz. - Mn_QuizController: initializes a quiz from
S_Quiz, builds/sequencesS_Questions (fixed count, random range or full), tracks points and correct/wrong counts, updates the progress slider and raisesonEndedQuiz/onPointsGained. - Mn_QuizUiManager:
Mn_Singleton; maps answer count → UI group, spawns/bindsMn_Answers, plays correct/wrong color feedback and auto-advances to the next question. - Mn_Question:
MonoBehaviourwrapping anS_Question; validates answers and raises the answered-correctly/badly UnityEvents with points. - Mn_Answer: a single clickable answer; runs the color feedback coroutine and reports completion back to the UI manager.
- SO_LinearQuiz / SO_GridQuiz: ScriptableObject quiz databases (linear list and grid variants) with CSV/JSON import-export helpers.
- S_Quiz / S_Question / S_QuizJsonPayload: serializable data structs for quizzes, questions and JSON transport.
© 2026 Marcello De Bonis. All rights reserved
Depends on 9
Used by 0
- No other module depends on it.
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 14 modules in total.
UGTKengine within an engine


