Okay, next time project, we are going to implement the method of dragging the icon to the shortcut bar in this issue.
Requirement: When the skill icon is dragged to the shortcut bar, when the mouse is released, the corresponding grid of the Hotbar will display the skill icon.
Idea: Very simple, we set an arbitrary icon under each shortcut bar, resize it to the appropriate size, and make it appear by default, when the skill icon is dragged to the shortcut bar, the icon is displayed and set to the icon of the skill.
Note: In order to follow the skills/items used in the Hotbar, we need to create an enum to manage the item types in the Hotbar.
public enum Shortcuttype
{
Skill,inventory,none
}
Class Shortcutui
{
Private Shortcuttype shorttype = Shorttype.none;
Private Uisprite icon;
private int id;
Private SkillInfo info;
void Awake ()
{
Icon = transform. Find ("icon"). Getcompnent<uisprite> ();
Icon.gameObject.SetAvtive (FALSE);
}
public void Setskill (int id)
{
This.id = ID;
info = skillsinfo._instance. Getskillinfobyid (ID);
Icon.gameObject.SetAvtive (TRUE);
Icon.spritename = Info.iconname;
Shorttype = Shorttpye.skill;
}
}
This enables you to drag skills to the shortcut bar.
UNITY3D-RPG Project Study notes (29)