UNITY3D-RPG Project Study notes (eight)

Source: Internet
Author: User

The previous project realized the task UI construction and interaction, and this day summarizes the processing of Pointers.

Requirements: pointers are different on different objects. The specific categories are: general, NPC, attack, lock, pick up five kinds.

First two, the Idea: set the replacement indicator method, in the NPC class call method, the script is as Follows:

① Create a Gamesetting class and build a singleton mode application

Class gamesetting

{

public static gamesetting _instance;

Public Texture2d normal_cursor;

Public Texture2d npc_talk_cursor;

Private Vector2 Hotpositon = vector2.zero;

Private Cursormode mode = cursormode.auto;

void Start ()

{

_instance = this;

}

public void Normal ()

{

Cursor.setcursor (normal_cursor, hotposition,mode);

}

public void Npc_talk ()

{

Cursor.setcursor (npc_talk_cursor, hotposition,mode);

}

}

② Create the NPC class, call the above method

Class NPC

{

void Onmouseenter ()

{

Gamesetting._instance. Npc_talk ();

}

void Onmouseexit ()

{

Gamesetting._instance. Normal ();

}

}

③ the Elder class as a subclass of npc, this day function can be realized.

This concludes Today.

UNITY3D-RPG Project Study notes (eight)

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.