Creating a Drag and Drop Spell Bar
Implementing a Drag and Drop Spell Bar:
by Mike Cook.
I am sure this has been covered somewhere in the Unity Forums, but I couldn't find any relevant information when I was starting out on this, so hopefully this tutorial will help someone starting out with Unity. Basically we will be mimicking the spell bar seen in such games as World of Warcraft, or Aion. Out custom drag and drop spell bar will have the following features:
- Easily add items to the spell bar.
- Drag and drop items off spell bar to delete them.
- Drag and drop item into empty slot to switch its location.
- Drag and drop item into occupied slot to swap the items.
- Drag and drop feature will be "sticky" meaning the user will have to drag a ways for the icon to disengage from the slot.
- Clicking an item will activate it, or use it.
- Right clicking while dragging will cancel the currently dragged item.
Step 1: Plan what you want to do before you do it
I have a very bad habit of "rushing" into things. I get an idea, and I HAVE TO IMPLEMENT IT THAT VERY SECOND. So I quickly slap things together in my main script and it usually results in a mess. I can't stress enough the fact that careful planning will go a long way.