This commit is contained in:
YangHua 2024-01-29 11:47:50 +08:00
commit 2da0c9d838
2 changed files with 17 additions and 0 deletions

View File

@ -1,6 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class GlobalFlag
{
@ -27,4 +29,13 @@ public class GlobalFlag
/// 红方蓝方
/// </summary>
public static int blueOrRed = -1;
public static bool CheckGuiRaycastObjects(EventSystem eventSystem, GraphicRaycaster graphicRaycaster)
{
PointerEventData eventData = new PointerEventData(eventSystem);
eventData.pressPosition = Input.mousePosition;
eventData.position = Input.mousePosition;
List<RaycastResult> list = new List<RaycastResult>();
graphicRaycaster.Raycast(eventData, list);
return list.Count > 0;
}
}

View File

@ -245,6 +245,8 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
Detection();
}
public EventSystem eventsystem;
public GraphicRaycaster RaycastInCanvas;
/// <summary>
/// 点击无线电显示UI
/// <summary>
@ -256,6 +258,10 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (GlobalFlag.CheckGuiRaycastObjects(eventsystem, RaycastInCanvas))
{
return;
}
if (EventSystem.current.IsPointerOverGameObject())
{
return;