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

Creating draggable barriers

It is time to create our draggable barriers. The player will be able to drag-and-drop the BarrierObject prefab in the Viewport GameObject. This BarrierObject prefab will look as shown in the following screenshot:

Creating draggable barriers

The BarrierObject prefab

First, we need to create our BarrierObject prefab's holder that will contain the draggable object:

  1. Select our UI GameObject.
  2. Create a new child with Alt + Shift + N and rename it as Barrier.
  3. Open the Widget Tool wizard by navigating to NGUI | Open and perform the given steps:
    1. Select Sprite for the Template parameter.
    2. Select Dark sprite for the Sprite field.
    3. With our Barrier GameObject selected, ...

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