You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.1 KiB
26 lines
1.1 KiB
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<RaycastResult> 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);
|
|
}
|
|
}
|
|
|