添加wrjUI弹出消失逻辑
This commit is contained in:
parent
0f2615cb75
commit
14bb009f8b
|
@ -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<EquipmentCommon>();
|
||||
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;
|
||||
/// <summary>
|
||||
/// UI 防穿透
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CheckGuiRaycastObjects()
|
||||
{
|
||||
PointerEventData eventData = new PointerEventData(eventsystem);
|
||||
eventData.pressPosition = Input.mousePosition;
|
||||
eventData.position = Input.mousePosition;
|
||||
List<RaycastResult> list = new List<RaycastResult>();
|
||||
RaycastInCanvas.Raycast(eventData, list);
|
||||
return list.Count > 0;
|
||||
}
|
||||
|
||||
public Vector3 GetScreenPosition(GameObject target)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue