A campaign menu allows the player to load scenarios, complete and unlock other scenarios. The demo RTS Engine campaign menu can be found under: RTS Engine/Demo/Scenes/CampaignMenu.unity
The campaign menu mainly uses the Scenario Loader component to achieve this.
- Scenarios: A list of scenarios and the target map scene names (per scenario) where they will be played at are assigned for each element of this list. You can have different scenarios played at the same map or use the same scenario for multiple maps. A scenario is unlocked and can be loaded by the player if it’s either the first scenario in this array or the previous scenario has been already completed.
- Scenario UI Prefab: This prefab will be cloned for each element in the above scenarios array and will allow the player to load a scenario if it’s unlocked. This prefab has the Scenario Menu UI component attached to it:
- Name Text: Child of the prefab object, this UI Text element will display the associated scenario’s name.
- Description Text: Child of the prefab object, this UI Text element will display the associated description’s name.
- Load Button: Child of the prefab object, this UI Button allows the player to load the associated scenario. In the On Click () event of the Button component, drag and drop the prefab object as the event trigger source and assign the event to ScenarioMenuUI -> OnLoadButtonClick.
- Scenario UI Parent: All the created instances of the above scenario UI prefab will be children objects of the object assigned in this field which is required to have a Grid Layout Group component.
- Reset Scenario Progress: In the demo campaign menu, there’s a button that allows to reset the player’s progress regarding completed scenarios. To achieve this, in the On Click() event of the Button component, drag and drop the object that has the Scenario Loader component attached to it as the event trigger source and assign the event to ScenarioLoader -> Reset.