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

Enlarging buttons on hover


Currently, only our button's color changes on mouse hover. We also want a smooth scale tween to make our button bigger to make the change more obvious. Good news: NGUI has a component for that.

UIButton Scale

The UIButton Scale component can trigger upscale or downscale animations on mouse hover or on press. Even though it is called UIButton Scale, it can work with any other non-button 2D or 3D GameObject matching these three conditions:

  1. It must have UIButton Scale attached.

  2. It must have a trigger Collider attached: box, capsule, sphere, and so on.

  3. It must reside on a layer included in the Event Mask of UICamera.

Now, let's see how it's used.

Usage

Let's add the UIButton Scale component to all three of our main menu buttons:

  1. In Hierarchy, select all three buttons: Exit, Options, and Play.

  2. At the bottom of the Inspector view, click on the Add Component button.

  3. Type scale with your keyboard to search for components with that word.

  4. Select Button Scale and hit Enter or click...