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

The elemental switch charging process


The PowerSource component already has the required code to switch from one element to another. Let's link UI elements to it in order to give feedback to the player. We'll first add a progress slider to indicate how long the elemental switch process takes.

The progress prefab

Let's create the Progress prefab, which will be a slider to indicate any kind of progress in the game—in this case, the elemental switch's duration, which will look like this:

Follow these steps to create our Progress prefab:

  1. In the Project view, enter progress in the search field.

  2. Drag Control - Simple Progress Bar into our InGame2DUI.

  3. Rename this new instance to Progress.

  4. For its attached UISprite component:

    • Change Size to 400 x 35

    • Set its Color Tint to {R:180, G: 180, B: 180, A: 220}

  5. For its attached UISlider component:

    • Set Value to 0

  6. Select its Foreground child GameObject, and for its UISprite:

    • Set Color Tint to {R: 255, G: 230, B: 200, A: 255}

  7. Select its Thumb child GameObject and delete...