首页 > 其他 > 详细

NGUI无法按住鼠标按住时无法监听OnHover事件

时间:2014-08-23 20:21:51      阅读:491      评论:0      收藏:0      [点我收藏+]

UICamera.cs

修改前:

 if ((!isPressed) && highlightChanged)
        {
            currentScheme = ControlScheme.Mouse;
            mTooltipTime = RealTime.time + tooltipDelay;
            mHover = mMouse[0].current;
            Notify(mHover, "OnHover", true);
        }

 

修改后:

 if ((!isPressed || isPressed) && highlightChanged)
        {
            currentScheme = ControlScheme.Mouse;
            mTooltipTime = RealTime.time + tooltipDelay;
            mHover = mMouse[0].current;
            Notify(mHover, "OnHover", true);
        }

 

或者加一个

if (Input.GetMouseButton(0) && highlightChanged)
        {
            currentScheme = ControlScheme.Mouse;
            mTooltipTime = RealTime.time + tooltipDelay;
            mHover = mMouse[0].current;
            Notify(mHover, "OnHover", true);
        }

 

if ((justPressed || !isPressed) && mHover != null && highlightChanged)
        {
            currentScheme = ControlScheme.Mouse;
            if (mTooltip != null) ShowTooltip(false);
            Notify(mHover, "OnHover", false);
            mHover = null;
        }

        if ((justPressed || Input.GetMouseButton(0)) && mHover != null && highlightChanged)
        {
            currentScheme = ControlScheme.Mouse;
            if (mTooltip != null) ShowTooltip(false);
            Notify(mHover, "OnHover", false);
            mHover = null;
        }

监听函数

 void OnHover(bool state)
    {
        Debug.Log(state+"OnHover"+gameObject.name);
    }

 

NGUI无法按住鼠标按住时无法监听OnHover事件

原文:http://www.cnblogs.com/123ing/p/3931679.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!