点击NPC改变鼠标图标

基类:

using UnityEngine;
using System.Collections;

public class CommonNPC : MonoBehaviour {

	// Use this for initialization
	void Start () {

	}

	// Update is called once per frame
	void Update () {

	}

    void OnMouseEnter()
    {
        MouseCursor._instance.SetCursorDialog();
    }
    void OnMouseExit()
    {
        MouseCursor._instance.SetCursorHand();
    }
}

  

子类:

using UnityEngine;
using System.Collections;

public class NPCTask : CommonNPC
{
    public TweenPosition TweenPos;
    public GameObject ConfirmButton;
    public GameObject CancelButton;
    public GameObject FinishButton;
    public UILabel Label;
    public int KilledAnimals;
    private bool IsTasking;
	// Use this for initialization
	void Start () {
        IsTasking = false;
        KilledAnimals = 0;
        FinishButton.SetActive(false);
	}

	void OnMouseOver()
    {
        if (Input.GetMouseButtonDown(0))
        {
            TweenPos.gameObject.SetActive(true);
            TweenPos.PlayForward();
            if(IsTasking==false)//接收任务
            {
                Label.text = "任务:杀死10个动物\n奖励:1000金币" ;
                FinishButton.SetActive(false);
                ConfirmButton.SetActive(true);
                CancelButton.SetActive(true);
            }
            else//提交任务
            {
                Label.text = "已经杀死" + KilledAnimals + "个动物";
                FinishButton.SetActive(false);
                ConfirmButton.SetActive(true);
                CancelButton.SetActive(true);
            }

        }
    }
    public void OnClickConfirm()//接收任务
    {
        Label.text = "已经杀死" + KilledAnimals + "个动物";
        FinishButton.SetActive(false);
        ConfirmButton.SetActive(true);
        CancelButton.SetActive(true);
        IsTasking = true;
    }
    public void OnClickCancel()
    {
        TweenPos.PlayReverse();
    }
    public void OnClickFinish()//提交任务
    {
        if(KilledAnimals>=10)
        {
            //
        }
    }

	// Update is called once per frame
	void Update () {

	}
}

  

时间: 2024-10-18 17:17:10

点击NPC改变鼠标图标的相关文章

点击时改变按钮图标

参考:http://www.mkyong.com/android/android-imagebutton-selector-example/ http://developer.android.com/guide/topics/ui/controls.html 1.在res/drawable文件夹下新建filename.xml文件: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:andr

改变鼠标图标

using System.Collections;using System.Collections.Generic;using UnityEngine; public class CursorManager : MonoBehaviour { public static CursorManager _instance; public Texture2D cursor_normal; public Texture2D cursor_npc_talk; private Vector2 hotspot

qt学习(三):鼠标图标改变

qt学习 (三):鼠标图标改变 当你进入一个美好的qt软件场景,比如游戏,电脑的黑白图标会让程序逊色不少, 1改图标要加光标的头文件, 2 载入光标图, 3 再设置改光标就可以了 1在头文件中加 #include <QtGui>  //光标类的父类 //再在public成员中声明换的函数void keyPressEvent(QKeyEvent *k); //声明按键换图的函数         .h文件    --注意头文件和声明 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Javascript:DOM事件(监听鼠标点击/释放,鼠标悬停/离开等)

使用Javascript可以对HTML页面上的各种事件进行监听,如鼠标点击/释放,鼠标悬停/离开,等等. 代码整理自w3school:http://www.w3school.com.cn 效果图: 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <

JS 改变鼠标样式

此片记录如何改变鼠标样式: document.body.style.cursor = "url(resource/pic/icons/magnifier3.cur) 12 12,crosshair";/* */ 可常用于地图上点击某个按钮后,鼠标样式设置 原文地址:https://www.cnblogs.com/ostrich-sunshine/p/8027020.html

android selector(如对TextView点击样式改变)

selector 1.selector 从单词的意思来说:选择者,选择器,就是对你的目标的控制. 从API来说: A controller for the selection of SelectableChannel objects. Selectable channels can be registered with a selector and get a SelectionKey that represents the registration. The keys are also add

使用C#改变鼠标的指针形状

1.在一个无标题的窗体中用MOUSEMOVE事件判断鼠标坐标是否到达窗体的边缘,如果是的话将鼠标指针改为可调整窗体大小的双向箭头. private   void   Form1_MouseMove(object sender,   System.Windows.Forms.MouseEventArgs e)    {    if(0   ==   e.X)    {        this.Cursor   =   Cursors.SizeWE;    }       //改成这样就可以了,很奇

jQuery改变鼠标经过行的背景颜色

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

BingMap改变鼠标样式【Map/Pushpin/Polygon】

<span style="font-size:18px;">Microsoft.Maps.Events.addHandler(map, "mousemove", function (e) { // get the HTML DOM Element that represents the Map var mapElem = map.getRootElement(); if (e.targetType === "map") { // Mo