码迷,mamicode.com
首页 > 其他好文 > 详细

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

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

标签:style   blog   color   div   log   amp   sp   on   res   

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事件

标签:style   blog   color   div   log   amp   sp   on   res   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!