- 最后登录
- 2019-12-25
- 注册时间
- 2012-8-24
- 阅读权限
- 90
- 积分
- 71088
- 纳金币
- 52336
- 精华
- 343
|
来自:F1085645195
private GraphicRaycaster _raycaster;//图形射线(只检测继承Graphic的组件,一般是UI)- private void Start()
- {
- _raycaster = FindObjectOfType<GraphicRaycaster>();
- }
- /// <summary>
- /// 检测是否点击UI
- /// </summary>
- /// <returns></returns>
- private bool IsUI()
- {
- PointerEventData data = new PointerEventData(EventSystem.current);
- data.pressPosition = Input.mousePosition;
- data.position = Input.mousePosition;
- List<RaycastResult> results = new List<RaycastResult>();
- _raycaster.Raycast(data, results);
- return results.Count > 0;
- }
复制代码 |
|