Book Image

NGUI for Unity

By : Charles Bernardoff (EURO)
Book Image

NGUI for Unity

By: Charles Bernardoff (EURO)

Overview of this book

Table of Contents (14 chapters)

Forwarding an event


Another component may be useful in some cases: UIForward Events. This component gives you the ability to send the events of the GameObject it's attached to to another GameObject in the scene. It can be useful, for example, to create a multiple selection. Let's try it to make it more clear. Perform the following steps:

  1. Select our Bomb GameObject in Grid.

  2. Attach a Forward Events component to it by navigating to Component | NGUI | Interaction and then perform the following steps:

    1. Drag our Time GameObject from Grid to the Target field.

    2. Check the OnHover Boolean.

    3. Check the OnPress Boolean.

    4. Check the OnDrag Boolean.

Click on the play button. If you hover, press, and drag the Bomb power, the Time power will also react the same way! That is what event forwarding does.

Now that you see how it works, you can remove the UIForward Events component from our Bomb GameObject.