So right now I have a this hierarchy:
Cube → Canvas → RawImage
And I want to get the coordinates of my click on the rawimage, but I dont know where to start right now.
- In the HoloToolkit is an GazeManager, where the raycast is performed and there is the property HitPosition. So by using GazeManager.Instance.HitPosition I should get the click position in world. But how do I get from this to the coordinates on the Canvas?
- I can trigger OnInputClicked(InputClickedEventData eventData) if I use IInputClickHandler. But from the eventData I wont get Information about the click.
- I found this but cant transfer it into my needs. Because his eventData has more options.
- I guess there wont be a difference to get the click from the rawimage, or the canvas or the cube, because they have all the same size.
Maybe what you need is to change your approach, I can see some solutions for this.
Change your Canvas
from Overlay
to World Space
and Raycast
the click to get a normal position, not Canvas
position.
If you have Canvas
in Overlay
, I think that Input.mousePosition
is directly proportional to RectTransform.position
, so there is your position.
For both, you can use IPointerClickHandler to detect the click on any UI element.