Book Image

NGUI for Unity

By : Charles Bernardoff (EURO)
Book Image

NGUI for Unity

By: Charles Bernardoff (EURO)

Overview of this book

Table of Contents (14 chapters)

Toggle


Now that we have a volume slider, let's add an enable/disable sound checkbox, which will turn down the volume to 0 and hide our volume slider.

First, create a toggle widget as follows:

  1. Select the Panel GameObject and create a new child with Alt + Shift + N.

  2. Rename that new child as Sound. It will be our sound toggle container.

  3. Navigate to NGUI | Open | Widget Wizard and perform the following steps:

    1. Select Toggle as Template.

    2. Select the Dark Sprite as Background.

    3. Select the X Sprite as Checkmark.

    4. With the Sound container selected, click on the Add To button.

A checkbox with a label has just been created as shown in the following screenshot:

Parameters

Select our new Toggle GameObject. Let's look at the UIToggle's Inspector parameters:

  • Group: This is the toggle's group. Toggles of the same group will act as radio buttons; only one of them can be checked at once.

  • Start State: This defines in which state the toggle will be at the start.

  • Animation: This is the animation that will play when the checkbox...