Creating a toggle group
In this recipe, you will learn how to create a toggle group. Often in menus, there is an opportunity to choose between different options, but the player can choose only one of them. A toggle group allows users to select just one of its toggles. To achieve this, we will use the Toggle (Script) component along with the Toggle Group (Script) component.
How to do it...
First of all, we need to create a panel in which our toggle elements will be placed. To do this, right-click on the Hierarchy panel and then on UI | Panel. Rename it to Toggle Group. Of course, it is possible to resize and place the panel as we wish.
The next step is to add a Toggle Group (Script) component to our Toggle Group panel. To do so, click on Add Component | UI | Toggle Group.
Now, we have to add our toggles. We can do this by right-clicking on the Toggle Group panel in the Hierarchy panel and selecting UI | Toggle. We can rename it to Toggle01 and duplicate it as many times as we want by pressing...