I have a world space canvas with a Image on it.
When i click on it, i need to get the X,Y relative to the image.
So if i clicked on its top left i would expect something near 0,0… Bottom Right 800,600
I’ve tried Screen Position & World Position, but there doesnt seem to be an object position.
The object definitly hits… but i need to know where it hit.
PointerEventData pointer = new PointerEventData(EventSystem.current);
pointer.position = Input.mousePosition;
var raycastResults = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointer, raycastResults);
foreach (var raycastHit in raycastResults)
{
Debug.Log($"Hit: {raycastHit.gameObject.name} Screen: {raycastHit.screenPosition}, World {raycastHit.worldPosition}");
}
I’m sure its something simple i just cant seem to find it? Can someone point me in the right direction?