I am having a hard time making sense of the coordinates I get from the characterInfo struct.
I’m using Unity 5.6
I have a TextMeshProUGUI object that is in Paging mode. When it gets to the end (last page) of text, I want to dynamically create a button underneath the last line of text.
To do this, I am getting the coordinates of the last character of text (I’ve also tried getting the baseline of the last line) and moving down on the y-axis a bit and justifying it to the left.
When I get the coords of the last character I do it like this:
Vector3 bottomLeft = mesh.textInfo.characterInfo [mesh.textInfo.characterCount - 1].bottomLeft;
This gives me a result of (56.2, -35.3, 0.0). (My Canvas is 300x300, something I arbitrarily set for now). However, if I manually place an object using the Scene Editor and align it with the last character, Unity tells me its RectTransform coords are (206.8, -63.5, 0).
Why the big discrepancy? What coordinate system does characterInfo use? I’ve tried converting the result I get from characterInfo using camera.WorldtoScreenPoint, camera.ScreentoWorldPoint, and transform.TransformPoint, but none of these result in coords that I can make sense of either.