NGUI无法按住鼠标按住时无法监听OnHover事件
2014-08-23 20:08
183 查看
UICamera.cs
修改前:
修改后:
或者加一个
监听函数
补充:
因为UICamera.cs 的Update函数里处理是:
修改前:
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); }
补充:
因为UICamera.cs 的Update函数里处理是:
void Update() { // Only the first UI layer should be processing events #if UNITY_EDITOR if (!Application.isPlaying || !handlesEvents) return; #else if (!handlesEvents) return; #endif current = this; // Process touch events first 如果是移动平台就调用的ProcessTouches()函数所以之前加的方法 在两个函数里都加上。 if (useTouch) ProcessTouches(); else if (useMouse) ProcessMouse();
相关文章推荐
- 你真的了解html代码的事件,离开焦点和聚焦焦点的动作的意思吗?onblur、focus?它们是点击才可以触发,而不是鼠标悬停,鼠标悬停是hover
- 主程序上无法监听到鼠标事件
- NGUI -- UICamera(监听输入事件,鼠标,键盘等)
- jquery中利用on绑定mouseenter事件与mouseleave事件实现鼠标hover事件
- oninput事件(解决onkeyup无法监听到复制黏贴)
- 监听Mac OS X的全局鼠标事件
- jQuery – 鼠标经过(hover)事件的延时处理
- 鼠标事件监听实例
- 解决ff下JQuery无法监听input的keyup事件
- JAVA:事件监听器之鼠标监听
- 全局监听SCREEN_ON和SCREEN_OFF的替代方法--监听屏幕解锁事件
- android hover监控鼠标移动事件
- Canvas 鼠标事件 无效——没有定义背景颜色,即是透明色,无法触发MouseLeftButtonDown事件
- jtable的鼠标事件监听
- comm.jar操作串口无法调用监听事件
- 鼠标事件的监听和使用
- js 监听 鼠标右击事件
- JavaScript当中事件监听与On事件重复出现时
- Google Maps API 进级:监听键盘鼠标事件 加载KML或者GEORSS文档
- AutoCompleteExtender无法触发textbox onchange事件的解决方法