I’m trying to position a centered tooltip window over a mouse pointer. This is my code, I’m calling this function in OnMouseOver for the combined label/item object. It works great at my 1920x1080 reference resolution but it gets wonky as the resolution gets larger.
toolTipDroppedItemPanel.transform.position = Input.mousePosition +
new Vector3(0, toolTipDroppedItemPanel.GetComponent<RectTransform>().rect.height, 0);
The behavior I’m seeing is the larger the resolution the more inaccurate the rec.height is, its almost like its not reporting the size of the window correctly. What I want is the window to always be above the cursor, which is what I thought rect.height would do.
In these examples below I have my mouse cursor directly over the purple cube just under the O in Longsword, you can see how as the resolution increases, the window slowly creeps down. I’m using a canvas scaler of 1920x1080, match Width, 100 Pixel reference, nothing I change in the scale seems to affect this weird rect.height behavior. Would super appreciate any pointers or help! Thanks!
1920x1080:
2560x1440:
3840x2160: