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)