In same cases, UI elements require some kind of interaction with the player, and the next three recipes will teach you how to create interactive panels. In this recipe, you will learn how to make a panel draggable. For instance, the player will be able to move the panel all around the screen by dragging it. This is useful when we want to allow the player to organize his UI with his logic and order. In order to do this, we will use the Event Trigger (Script) component and develop a script to handle the interaction.
To begin, we can create a panel by right-clicking on the Hierarchy panel and then on UI | Panel. We should also resize it so that we can see the entire panel on the screen.
Now we need to create our script on the panel, so we click on Add Component | New Script, name it DraggablePanelScript, and then click on Create and Add.
Double-click on the script to edit it. This time, we don't need to add the
using UnityEngine.UI;
statement at the beginning...