Unity 手指检测屏幕点击区域

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
        {
 
    /*        Ray ray = uiCamera.ScreenPointToRay(Input.mousePosition);
            var hitCount = Physics.RaycastNonAlloc(ray,m_hit,1000, m_layerMask);
            Debug.DrawRay(ray.origin,ray.direction*1000,Color.red,10);
            if (hitCount > 0)
            {
                Debug.Log("IsPickDown......");
                Debug.DrawLine(ray.origin, m_hit[0].point, Color.green);
                GameObject hitObj = m_hit[0].collider.gameObject;
                 
                if (hitObj.tag == "DispatchMap")
                {
                }
            }*/
 
      /*      RaycastHit2D hit = Physics2D.Raycast(uiCamera.ScreenToWorldPoint(Input.mousePosition), uiCamera.transform.forward, 1000);
            if (hit.collider != null)
            {
                print("按下3");
            }*/
#if UNITY_ANDROID || UNITY_IPHONE
            if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
#else
            if (EventSystem.current.IsPointerOverGameObject())
#endif
            {
                PointerEventData pe = new PointerEventData(EventSystem.current);
                pe.position = Input.mousePosition;
                EventSystem.current.RaycastAll(pe, m_hit);
                bool isClose = true;
                for (int i = 0; i < m_hit.Count; i++)
                {
                    if (m_hit[i].gameObject.tag == "CommonTipBg")
                    {
                        isClose = false;
                        break;
                    }
                }
                if (isClose)
                {
                    LuaManager.Instance.CSharpCallLuaLogic("CloseCommonTipsFunc");
                }
            }
        }

  用于可穿透点击:点击区域并且可以出现下面的点击事件

posted @   姿态H  阅读(582)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
点击右上角即可分享
微信分享提示