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:
The BarrierObject prefab
First, we need to create our BarrierObject prefab's holder that will contain the draggable object:
Select our UI GameObject.
Create a new child with Alt + Shift + N and rename it as
Barrier
.Open the Widget Tool wizard by navigating to NGUI | Open and perform the given steps:
Select Sprite for the Template parameter.
Select Dark sprite for the Sprite field.
With our Barrier GameObject selected, click on the Add To button.
Select our new barrier's Sprite (Dark) GameObject and perform the following steps:
Rename it as
Background
.Set its Sprite Type to Sliced.
Set its Color Tint to {
0
,250
,250
,170
}.Set its Depth value to
0
.Set its Dimensions to
200
x200
.
Select our Barrier GameObject.
Attach a collider to it by navigating to NGUI | Attach...