if (RectTransformUtility.RectangleContainsScreenPoint(transform.GetComponent<RectTransform>(),
Input.mousePosition, Camera.main))
{
Debug.Log("在遮挡范围内");
OnScroll(Input.mouseScrollDelta);
}
public static GameObject GetUI(GameObject canvas)
{
if (canvas.GetComponent<GraphicRaycaster>() == null) return null;
PointerEventData pointerEventData = new PointerEventData(EventSystem.current);
pointerEventData.position = Input.mousePosition;
GraphicRaycaster gr = canvas.GetComponent<GraphicRaycaster>();
List<RaycastResult> results = new List<RaycastResult>();
gr.Raycast(pointerEventData, results);
if (results.Count != 0)
{
return results[0].gameObject;
}
return null;
}