- Home /
How to get the intersection point between a UI WorldSpace with a Raycast from a Gazer ?
Hi, I have a gazer which is basically a quad that sits in front of the main camera (at its center position) and this gazer is a child of Camera and when the camera rotates at any angle the gazer remain in the center position of the camera and rotates as well with the camera as parent transform. I have a UI Canvas set in world space and I need to find the intersection point between a raycast from the Gazer (transform.forward) and the UI. How can I achieve this ? I've try with Physics.Raycast but this only works for regular objects and colliders and not with the UI, and I also tried out with the GraphicRaycaster.Raycast, but here I cannot assign the proper coordonates of the origin of point. I tried with screenPoint = Camera.main.WorldToScreenPoint(transform.position); PointerEventData ed = new PointerEventData(m_EventSystem); ed.position = screenPoint; m_Raycaster.Raycast(ed, list);
but eachtime the origin point is in the center of the screen (where tha gazer sits). Here I would like to change the origin point as you see in the screenshot in the bottom right part.
Basically I want to change color of the material of the quad when the gazer is intersecting with an UI element.