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

Creating tooltips


Let's use the OnTooltip() event to show a tooltip for our buttons and different options, as shown in the following screenshot:

The tooltip object shown in the preceding screenshot, which we are going to create, is composed of four elements:

  • Tooltip: The tooltip container, with the Tooltip component attached.

  • Background: The background sprite that wraps around Label.

  • Border: A yellow border that wraps around Background.

  • Label: The label that displays the tooltip's text.

We will also make sure the tooltip is localized using NGUI methods.

The tooltip object

In order to create the tooltip object, we'll first create its visual elements (widgets), and then we'll attach the Tooltip component to it in order to define it as NGUI's tooltip.

Widgets

First, we need to create the tooltip object's visual elements:

  1. Select our UI Root GameObject in the Hierarchy view.

  2. Hit Alt + Shift + N to create a new empty child GameObject.

  3. Rename this new child from GameObject to Tooltip.

  4. Add the NGUI Panel...