Multi-line text, figuring out the specific character at position.

What I’m trying to do: There’s a multi-line UI Text element on screen with a big chunk of text on it. When the user taps on that text, I would like to know which word he has tapped on.

To get to that, I would like to get the actual string that is shown on screen, with the line feeds added by Unity to get the text to fit in the screen width.

Because even though I can figure out which line of text the user tapped on from math, it’s useless unless I know how Unity has split the string to make the text block.

(Alternatively, I’m currently thinking of simply scrapping the single text block idea and generating words one-by-one as gameobjects with colliders. Concerned that it will slow the app down and will create kerning issues, thoughts?)

Thanks!

This is all covered in the TextGenerator class which I had strangely overlooked. Leaving the answer here for future ref.