O'Reilly logo

NGUI for Unity by Charles Bernardoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. C# with NGUI

In this chapter, we will talk about C# scripting with NGUI. We will learn how to handle events and interact with them. We'll use them to:

  • Play animations and Tweens
  • Change labels using localized text through code
  • Add keyboard keys for our UI
  • Create notifications and tool tips

We will also see some of the NGUI's code-oriented components, such as event forwarding and message sending.

Events methods

When using C# with NGUI, there are some methods that you will regularly use when you need to know if your object is currently hovered upon, pressed, or clicked.

If you attach a script to any object with a collider on it (for example, a button or a 3D object), you can add the following useful methods in the script to catch events:

  • OnHover(bool ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required