UNITY3D-RPG Project Study notes (29)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.