using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class UCRaycaster : PhysicsRaycaster { //put this component in monitor camera, point RaycasterCamera to scene camera public Camera MonitorCamera; public override void Raycast(PointerEventData eventData, List resultAppendList) { //Debug.Log(eventData.position); if(MonitorCamera != null) { Vector2 position = eventData.position; position.x /= MonitorCamera.pixelRect.width; position.y /= MonitorCamera.pixelRect.height; position.x *= eventCamera.pixelRect.width; position.y *= eventCamera.pixelRect.height; eventData.position = position; //Debug.Log("Screen Size: " + Screen.width + " " + Screen.height); //Debug.Log("Target Size: " + MonitorCamera.pixelRect.width + " " + MonitorCamera.pixelRect.height); //Debug.Log(eventData.position); } base.Raycast(eventData, resultAppendList); } }