I know about MouseToWorldPosition and that stuff, but I want to get the position of an image I click on. If I click in the center of an image, how can I get (0.5, 0.5)? Or bottom left (0,0)?
You’ll need to work out what the mouse position is relative to the image origin. So for example, given a mouse position in screen space in a vector mousePos, and the image’s position in a vector imagePos, and screen origin (0, 0) top left and image origin (0, 0) also top left:
var posInImage = mousePos - imagePos;
if (posInImage.x >= 0 && posInImage.x < imageWidth &&
posInImage.y >= 0 && posInImage.y < imageHeight)
{
// The mouse click is inside the image, so calculate a normalised value for the click.
normalisedPos.x = posInImage.x / imageWidth;
normalisedPos.y = posInImage.y / imageHeight;
}
Note that if you want the bottom left to be (0, 0) you’ll have to flip the height:
normalisedPos.y = imageHeight - normalisedPos.y;