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

时间:2014-08-23 20:21:51   收藏:0   阅读:492

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);
    }

 

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!