WrapTextMesh

Description
Ever wanted to use a TextMesh with text that just fit in a certain width but your font didn't have uniform widths, so using character counts was pointless?

This solution uses actual kerning data from the imported font to determine the most appropriate place to break the line.

Important Note: This will not work with dynamic fonts.

Usage
There are 2 ways you can use this script in it's current form:

1. Apply it to a TextMesh and use the WrapOnStart feature that wraps the text that's already on the mesh as soon as the scene is initialized.

2. If new text has been dynamically assigned to the TextMesh and wrapping needs to be done on a fresh string then just call the Wrap function directly to the desired width: