This Unity Tool is a Level Generation System designed to create and display interactive levels with images, questions, and multiple-choice answers. It's built to be easily extensible and configurable through ScriptableObjects.
Create the following hierarchy in your Unity scene:
GameController
LevelGenerator
UICanvas
└── LevelDisplay
├── QuestionImage
├── QuestionText
└── OptionsContainer
Create LevelConfig ScriptableObjects for each level (e.g., Level1_Easy, Level2_Medium, Level3_Hard).
- Attach
GameController
script to the GameController GameObject - Attach
LevelGenerator
script to the LevelGenerator GameObject - Attach
LevelController
script to the UICanvas/LevelDisplay GameObject
Configure the following in the Unity Inspector:
- GameController:
- Assign LevelController and LevelGenerator references
- LevelGenerator:
- Add LevelConfig ScriptableObjects
- Set number of levels to generate
- LevelController:
- Assign references for QuestionImage, QuestionText, and OptionsContainer
Prepare three images for each level:
- Question Image: Displayed at the start of the question
- Correct Answer Image: Shown when the correct answer is selected
- Incorrect Answer Image: Displayed when an incorrect answer is chosen
- Create LevelConfig ScriptableObjects for each desired level type
- Configure each LevelConfig with:
- Question Image
- Correct Answer Image
- Incorrect Answer Image
- Word options
- Correct words
- Question text
- Add created LevelConfigs to the LevelGenerator component
- Set the desired number of levels to generate
- Run the scene
The system will automatically:
- Generate levels based on the provided configs
- Display images, questions, and options for each level
- Handle user input and level progression
-
Factory Pattern: Used in
LevelFactory
to createLevel
objects fromLevelConfig
ScriptableObjects. -
Command Pattern: Implicitly used in option selection handlers for answer checking and level progression.
-
Observer Pattern: Likely used for updating UI elements and managing game state changes.
-
Singleton: Possibly used for the GameController (not explicitly shown, but common in Unity projects).
-
ScriptableObject Architecture: Used for flexible and reusable level configurations.
The system is designed for easy expansion:
- Create new LevelConfig ScriptableObjects for additional level types
- Add new images for different question types or feedback
- Extend the LevelController to handle new types of interactions or display elements
- Modify the GameController to include additional game logic or scoring systems
By following this structure, you can easily add new levels, question types, or gameplay mechanics without significant changes to the core system.
While this system uses static images, it can be easily adapted to use animations:
- Replace the
QuestionImage
with an animated component (e.g., using Unity's Animation system or a third-party solution). - Update the
LevelConfig
ScriptableObject to include references to animation clips instead of static images. - Modify the
LevelController
to trigger animations instead of swapping images.
This flexibility allows you to enhance the visual feedback of the system without major structural changes.