Unity uGUI鼠标击穿检测
2015-11-02 21:49
489 查看
uGUI没有一个标志或接口检测是否点击在了UI上,这点不太友好,不过也有解。
E.g.
不像网上有些人说的,EventSystem.Current.IsPointerOverGameObject (Input.GetTouch(0).fingerId)中iOS上始终返回false,而在PC和Mac上功能都正常,能够识别是否点击在了UI上,姑且认为这是Unity的bug吧(至少Unity5.1.1f上存在)。
E.g.
Using System.EventSystem; ... if (Input.touchCount > 0 || Input.GetMouseButton (0)) { Vector2 point = new Vector2(Input.mousePosition.x, Input.mousePosition.y); PointerEventData eventData = new PointerEventData (EventSystem.Current); eventData.position = point; tempRaycastResultList.Clear(); EventSystem.current.RaycastAll (eventData, tempRaycastResultList); return tempRaycastResultList.Count > 0; }
不像网上有些人说的,EventSystem.Current.IsPointerOverGameObject (Input.GetTouch(0).fingerId)中iOS上始终返回false,而在PC和Mac上功能都正常,能够识别是否点击在了UI上,姑且认为这是Unity的bug吧(至少Unity5.1.1f上存在)。
相关文章推荐
- Unity Shader:Blur
- 在Asset Store上购买unity插件
- 辛巴学院-Unity-剑英的c#提高篇(一)主循环
- 在Unity中获得一个物体的所有子物体包括孙物体。
- unity3d 物理引擎
- Kinect2.0+Unity之环境搭建
- 设置unity 编译文件到android项目
- 20151102—unity3D随笔
- Unity5 如何做资源管理和增量更新
- Microsoft.Practices.Unity mvc controller 注入
- Unity4.3 遮挡剔除:基本知识
- Unity3d游戏场景优化杂谈
- [unity2D] 迷你拼图
- Unity3D摄像机跟随物体移动的代码控制
- 使用Unity3D创建一个幸运转盘
- Unity中图片去色两种方案
- 在Unity中写单元测试
- Unity3D游戏开发之SQLite让数据库开发更简单
- 【笨木头Unity】入门之旅005:正常人都要掌握的操作
- Unity基础小案例--跳动的小球、自定义第一人称控制器