Creating a Difficulty System toggle switch
Objective: Have a Difficulty system connected to toggle switches.
We now have the ability to control the difficulty of a game with some toggles! First thing we will need to do is create an Empty object under the Canvas. On the empty game object, we can add the toggle group component.
Now we can create three toggles under the Toggle Group. I Named them Easy, Medium, and Hard.
If you drop down the toggle, you will find more objects. We can select Label to change the text in Game View.
A toggle has a Background and a check mark as a child. These are the images we see can see in game.
Since we are doing a difficulty here, we can’t have multiple toggles selected at once. To fix this we need to select each toggle and add ToggleGroup to the Toggle component.
With that we can’t select two toggles in the same group. The last thing we could do is create a script. In the script create a method for Easy, Medium, and Hard. For now in these scripts we will just do Debug.Log() but in the future we could use to change the difficulty of the game.
We will create an empty object and attach the script to it.
Go to each Toggle and in the OnValueChange, we can add in Manager and select the method for each toggle.
With that we can select the difficulty. Thank you for reading and have a wonderful day!