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

Summary


In this chapter, you learned how to create in-game 2D user interfaces and how to implement them in a simple game example. We made sure our power sources were draggable in the 3D space using the UIDragObject component by the use of its Movement vector parameter to limit the movement to a horizontal plane.

We used NGUI's OnPress() event on 3D world elements to add character movement when the player clicks on the ground or any other interactive element.

We have created the elemental switch UI for the player to switch the power source's current element using the four Fire, Ice, Lightning, and Water buttons. The current element's button is grayed out using the isEnabled Boolean.

Using the new FollowObject component we created, we can now force a 2D UI widget to follow any object within the 3D scene with a configurable Offset vector. It was used to make sure the elemental switch UI remains displayed over the concerned power source.

A progress bar has been added to the power sources in order...