Comment on page
To be attached to an object that can be dragged, meant for use with the Drag and Drop system. The intent of this componenet is that you add it to the Unity Engine UI object you want to be draggable, it could represent a spell, inventory item, etc.
You can use the static members listed below to understand the state of the drag and drop system as a whole.
The object currently being dragged if any
public static DragItem dragObject;
You will notice the Drag Item has a
Typesfield which takes any kind of scriptable object you would like to place in it. This operates much like a "tag" system and in fact we provide a scriptable object
ScriptableTagthat contains no data and is meant for exsactly this sort of use. You can read more about ScriptableTag here.
Lets assume we are using Drag and Drop for an ability bar system. Lets then assume we have weapon and spell abilities which can be "normal" or "ultimate" and that 1 of our slots the "ultimate" slot can take any normal ability or ultimate ability but that normal slots cannot take ultimate abilities.
We would then create scriptable objects as such
We would add all of the scriptable objects to our Drop Item that matched, so all of them would get "Ability", all of the weapon abilities but not the spells would get "Weapon", all the spells but not weapon abilities would get "Spell" and so on.
We can now configure the Drop Containers accordingly. That is we can indicate that they take Abilities and which one allows for Ultimate or excludes Ultimate. You can read more about Drop Container and its filter in its article.
You can see a working example of this sort of conditional limits in the examples. In our examples we have slots and items that have 2 attributes color and number. some slots have just 1 attribute some have both some have none e.g. can take any item. This system lets you insure your users cant drag abilities to inventory slots, cant put a helmet on there feet, etc.
Occurs when the drag operation starts
Occurs when the drop operation is accepted
Occurs when the drop operation is cancled