鼠标双击

<pre name="code" class="csharp">using System;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class donghuaxianshi : MonoBehaviour {
    public GameObject manyoudonghua;
    public GameObject shipin;
    public RawImage texture;
    public Animator animator;
    MovieTexture movTexture;
    private bool mouseDownStatus;
    private int mouseDownCount;
    private float lastTime;
    private float currentTime;
    private Action clickCallback;
    private Action doubleCallback;

    // Use this for initialization
    void Start () {
        GameObject.Find("A").GetComponent<Animator>().speed = 0;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (!this.mouseDownStatus)
            {
                this.mouseDownStatus = true;
                //Debug.Log("Click !");
                if (this.clickCallback != null) this.clickCallback();

                // 如果按住数量为 0
                if (this.mouseDownCount == 0)
                {
                    // 记录最后时间
                    this.lastTime = Time.realtimeSinceStartup;
                }
                this.mouseDownCount++;
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            //Debug.Log("Up !");
            this.mouseDownStatus = false;
        }

        if (this.mouseDownStatus)
        {
            //Debug.Log("Hold !");
            if (this.mouseDownCount >= 2)
            {


                this.currentTime = Time.realtimeSinceStartup;
                if (this.currentTime - this.lastTime < 0.1f)
                {
                    this.lastTime = this.currentTime;
                    this.mouseDownCount = 0;
                    //Debug.Log("Double Click");
                    if (this.doubleCallback != null) this.doubleCallback();


                    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        if (hit.transform.tag == "电脑")
                        {
                            manyoudonghua.SetActive(true);
                            manyoudonghua.transform.position = new Vector2(Input.mousePosition.x + 120, Input.mousePosition.y);

                        }
                    }
                }
                else
                {
                    // 记录最后时间
                    this.lastTime = Time.realtimeSinceStartup;
                    this.mouseDownCount = 1;
                }


            }
        }
    }
    public void donghua()
    {
        print("wanglijuan");
        GameObject.Find("A").GetComponent<Animator>().Play("Take 001", 0, 0);
        GameObject.Find("A").GetComponent<Animator>().speed = 1;
    }


    public void _shipin()
    {
        shipin.SetActive(true);
        texture.texture = (Texture)Resources.Load("A");
        movTexture = (MovieTexture)Resources.Load("A");
        movTexture.loop = true;
        movTexture.Play();
    }

    public void _shipinbofang()
    {
        movTexture.Play();
    }

    public void _shipinzanting()
    {
        movTexture.Stop();
    }

    public void manyoudonghuaguanbi()
    {
        manyoudonghua.SetActive(false);
        shipin.SetActive(false);

    }
}



                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值