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

Adding a checkbox


It would be great to add a checkbox to enable or disable sound for the game. Before we continue, let's prepare a container box for our future checkbox:

  1. Select our UI Root | Options GameObject.

  2. Create a new child empty GameObject by pressing Alt + Shift + N.

  3. Rename this new empty GameObject to Sound.

We'll add the UISprite component to our new Sound holder GameObject to create the sound toggle's box background.

Select our UI Root | Options | Sound GameObject:

  1. Click on the Add Component button in the Inspector view.

  2. Type in sprite with your keyboard.

  3. Select NGUI Sprite with your keyboard arrows and hit Enter.

Follow these steps to configure the new UISprite component on our Sound GameObject:

  1. Select the Wooden Atlas for the Atlas parameter.

  2. Change Sprite to Highlight – Thin.

  3. Change the sprite Type parameter to Sliced.

  4. Change its Color Tint parameter to {R: 180, G: 125, B: 50, A: 255}.

  5. Set Size to 460 x 280.

  6. Set its Transform position to {550, 85, 0}.

Good, we have our background sprite. We...