Here is the setup.
I have a map as a background.
I’m using cubes at specific location to use the mouseover behavior in order to have a pop up show information about that location. (the pop up is functioning great and held together in an empty object)
the cubes have an SO containing all their information and specifically a vector2 for the transform.position.
Also note that I have the camera set to orthographic (size 5) because I want to be able to move the camera with click/drag.
Here’s where I’m completely lost/stuck.
I have a mouseover function on the script attached to the cube and it gets it’s location (transform.position) from the SO without a problem, however when the pop-up comes up it appears at a completely different vector2.
When I debug I do get the right x/y values.
I’ve tried looking into WorldToScreen etc… but this doesn’t seem to be the problem.
I updated the code to have that line use tmpPos = Camera.main.WorldToScreenPoint( new Vector3(thisTown.townMapLoc.x, thisTown.townMapLoc.y, 0f));
But now the UI popup goes well into the 10000’s on both X & Y axis.
It’s harder with world space canvas. You will need a more complicated calculation. WorldToScreenPoint is only good for 2D canvas’s that match the screen size.