diff --git a/Assets/Zion/Scripts/Adam/WRJManager.cs b/Assets/Zion/Scripts/Adam/WRJManager.cs index ff102fa8..da7d3ba4 100644 --- a/Assets/Zion/Scripts/Adam/WRJManager.cs +++ b/Assets/Zion/Scripts/Adam/WRJManager.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; namespace Assets.Zion.Scripts.Adam { @@ -25,16 +27,25 @@ namespace Assets.Zion.Scripts.Adam RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, 1000)) { + if (CheckGuiRaycastObjects()) return; EquipmentCommon ec = hitInfo.collider.GetComponent(); if (ec != null && ec.isPlayer) { - if (hitInfo.collider.tag == "WRJ") + if (hitInfo.collider.tag == "WRJ" ) { wrjMenuSetPanel.localScale = Vector3.one; Vector3 posItem = GetScreenPosition(hitInfo.collider.gameObject); wrjMenuSetPanel.gameObject.SetActive(true); wrjMenuSetPanel.anchoredPosition = new Vector3(posItem.x + 100f, posItem.y, posItem.z); } + else + { + wrjMenuSetPanel.localScale = Vector3.zero; + } + } + else + { + wrjMenuSetPanel.localScale = Vector3.zero; } } else @@ -44,9 +55,21 @@ namespace Assets.Zion.Scripts.Adam } } - - - + public EventSystem eventsystem; + public GraphicRaycaster RaycastInCanvas; + /// + /// UI 防穿透 + /// + /// + public bool CheckGuiRaycastObjects() + { + PointerEventData eventData = new PointerEventData(eventsystem); + eventData.pressPosition = Input.mousePosition; + eventData.position = Input.mousePosition; + List list = new List(); + RaycastInCanvas.Raycast(eventData, list); + return list.Count > 0; + } public Vector3 GetScreenPosition(GameObject target) {