O'Reilly logo

Unity UI Cookbook by Francesco Sapio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. 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.
  2. The next step is to add a Toggle Group (Script) component to our Toggle Group panel. To do so, click on Add Component ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required