Reputation: 433
I'm attempting to position a tooltip to be directly below an icon. The structure is:
Main Canvas
- Panel
- UI Element
Tooltip Canvas
- Tooltip Icon
When mousing over an icon, I'm attempting to set the position of the tooltip to be just under the ui element. How does one get the absolute position of the ui element?
So far I've tried both
float absolute_x = icon.position.x;
or
float absolute_x = icon.anchoredPosition.x;
which only wield the relative position to the main canvas, not the absolute position on the UI.
Upvotes: 1
Views: 2038
Reputation: 507
First get the Rectransform
public RectTransform UIElement;
then get position relative to the parent canvas
UIElement.localPosition.y
Upvotes: 2