I’ve looked everywhere, but can’t find a solution even remotely close to what I’m looking for.
Building my dialogue system, I want to display text and, if it’s too long for the dialogue box, truncate it and store the truncated text in a variable (to be displayed next).
So! Is there a way to get the truncated string?
Or! Is there at least a way to find out if the string has been truncated?
Or! At the very, very least, is there a way to get the pixel size of a string? (preferably with the option of multi-line sizes too).
This looks like a solution http://stackoverflow.com/questions/2776673/how-do-i-truncate-a-net-string
you can check if the original string and the string that did run thou the function differ in length.
That way you know if it has been truncated;
For the text hight i do not have a solution right now, have to look inside the text-component some more.
which returns the number of characters that were actually displayed. You could then take the full string minus the number displayed and get a substring of the remaining, undisplayed text.
My only issue now is that this only returns the displayed number AFTER its been displayed, which prevents me from displaying any kind of prompt for the remaining text along with it. Back to tinkering!
I know this is an old post, but for those that run into this, here’s how I got around it:
text01.text = someString;
//force canvas update so we can get correct result from cachedTextGenerator
Canvas.ForceUpdateCanvases ();
int truncateIndex = text01.cachedTextGenerator.characterCountVisible;
text01Continued.text = someString.Substring (truncateIndex);