"How to find the X,Y on the object a ray cast hit in world space canvas?" (859167)

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?

Please note that this is UI and not physics (the physics teams don’t implement this stuff). It’s UI/Event casting; can use physics or graphics. You’re better off posting in the UI forum here.

Someone might answer here but it’s not related to anything in physics and all about Canvas/UI.

1 Like

Thanks, for anyone who finds themselves here… link How to find the X,Y on the object a ray cast hit in world space canvas? - Unity Forum

1 Like