I'm trying to draw a line from one point to another using a UISprite (for various reasons, it needs to be a UISprite and not, say, a Vectrosity line or a LineRenderer).
I've tried to apply my usual method of making an object touch two points:
controlTransform.position = sourcePoint;
controlTransform.LookAt(targetPoint);
sprite.transform.localScale = new Vector3(1f, (targetPoint-sourcePoint).magnitude, 1f);
Now, this would work if the sprite's 1/1/1 scale set it exactly equal to one unity unit, but of course that is not how sprites work.
What I need to do is set the scale's Y value to (target-source).magnitude * sprite.pixelsPerUnit. I determined this through just brute-forcing the scaling to match what I wanted, and it's roughly that value, but I can't hardcode any numbers in because I don't know what will change later.
Unfortunately I am horrendous at math and my searching has not turned up anything that looks promising as far as converting UISprite pixels to a "real" size. Can anyone offer insight or solutions to this?