The power sources are prefabs. There are two of them already instantiated in the scene. In order to make them draggable, we simply have to use the UIDragObject
component.
First things first; we need GameCamera
to have the
UICamera
component attached to it in order to trigger events on 3D world objects like the ground or the power sources. To get the required results, perform the following steps:
Select the GameCamera GameObject.
Click on the Add Component button in the Inspector view.
Type in
uicam
to search for components with that name.Select NGUI Event System (
UICamera
), and hit Enter or click on it.Set the newly attached
UICamera
component's Event Type to 3D World.Make sure Event Mask is set to Everything and not just 2DUI.
OK. The GameCamera GameObject is now ready to trigger events on 3D objects. We can now make our power sources draggable objects.