Book Image

Learning NGUI for Unity

By : Charles Bernardoff (EURO)
Book Image

Learning NGUI for Unity

By: Charles Bernardoff (EURO)

Overview of this book

Table of Contents (17 chapters)
Learning NGUI for Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Slider


The player can now enable or disable sound. It would be even better if they could adjust the game's music and sound effect volumes separately. We can do that!

Before we continue, we'll use the sound toggle box we just created to build a new container box for our future sliders:

  1. With our Options | Sound GameObject selected, hit Ctrl + D to duplicate it:

    • Rename our new duplicate to Volume

    • Set its Transform position to {550, -220, 0}

  2. Select the Volume | Label GameObject:

    • Change Text to Volume

  3. Now, select our Volume | Checkbox GameObject and delete it.

We are now ready to create our first slider.

Creating the slider

Drag the Colored Scrollbar (1) from our Prefab Toolbar inside our new Volume GameObject in the Hierarchy view, as shown in the following screenshot:

A new slider appears on the scene. Hit Unity's play button. The slider's thumb can be dragged along the horizontal axis. You may also click anywhere on the slider to jump to the pointed position. The current amount is displayed as a...