zoukankan      html  css  js  c++  java
  • Unity EventSystem.current.IsPointerOverGameObject() 真机BUG

    版本号:**2017.4.29f **

    判断是否点击触摸在UI上所调用的 EventSystem.current.IsPointerOverGameObject() 接口有问题,在真机无法返回正确判断。

    处理办法:
    1、UI事件发出射线检测

        public static bool IsPointerOverGameObject()
        {
            PointerEventData eventData = new PointerEventData(UnityEngine.EventSystems.EventSystem.current);
            eventData.pressPosition = Input.mousePosition;
            eventData.position = Input.mousePosition;
    
            List<RaycastResult> list = new List<RaycastResult>();
            UnityEngine.EventSystems.EventSystem.current.RaycastAll(eventData, list);
    
            return list.Count > 0;
        }
    
    

    2、Canvas的GraphicRaycaster发出射线检测

    
        public bool IsPointerOverGameObject(Canvas canvas)
        {
            PointerEventData eventData = new PointerEventData(EventSystem.current);
            eventData.pressPosition = Input.mousePosition;
            eventData.position = Input.mousePosition;
    
            GraphicRaycaster uiRaycaster = canvas.gameObject.GetComponent<GraphicRaycaster>();
    
            List<RaycastResult> results = new List<RaycastResult>();
            uiRaycaster.Raycast(eventData, results);
    
            return results.Count > 0;
        }
    
  • 相关阅读:
    nodejs cookie与session
    nodejs body-parser 解析post数据
    js四舍五入
    escape()、encodeURI()、encodeURIComponent()区别详解
    nodejs 搭建简易服务器
    ejs常用语法
    window.location
    response.writeHead
    response.write
    git 常用指令
  • 原文地址:https://www.cnblogs.com/ZeroyiQ/p/12096738.html
Copyright © 2011-2022 走看看