添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
深情的煎鸡蛋  ·  docker ...·  3 周前    · 

无奈之下自己写了一套

#region 模块信息
// **********************************************************************
// Please contact me if you have any questions
// File Name:             MButton.cs
// Author:                子龙
//QQ / Whacth         991959229 / taylorgege
// **********************************************************************
#endregion
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.EventSystems;
public class MButton : Button
    private const float M_Time = 2;
    private float timmer = 0;
    private bool isDown = false;
    protected override void Awake()
        onClick.AddListener(OnClick);
    private void Update()
        //if (isDown)
        //    timmer += Time.deltaTime;
        //    if (timmer >= M_Time)
        //    {
        //        timmer = 0;
        //        interactable = true;
        //        isDown = false;
        //    }
        //}// 如果按钮是被按下状态
    public void OnClick()
        //interactable = false;
        //isDown = true;
    // 延迟时间
    private float delay = 0.2f;
    private bool IsUp = false;
    private float lastIsDownTime;
    protected MButton()
        m_onDoubleClick = new ButtonClickedEvent();
    private ButtonClickedEvent m_onDoubleClick;
    public ButtonClickedEvent OnDoubleClick
        get { return m_onDoubleClick; }
        set { m_onDoubleClick = value; }
    public override void OnPointerDown(PointerEventData eventData)
        base.OnPointerDown(eventData);
        if (Time.time - lastIsDownTime <= delay)
            m_onDoubleClick.Invoke();
    public override void OnPointerUp(PointerEventData eventData)
        base.OnPointerUp(eventData);
        lastIsDownTime = Time.time;