Created
December 28, 2013 07:42
-
-
Save radiatoryang/8157056 to your computer and use it in GitHub Desktop.
Word Wrapping in Unity C#, based on some Tale of Tales code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// courtesy of Tale of Tales! | |
string WordWrap(string text, int lineLength) { | |
for (int i = lineLength; i < text.Length; i += lineLength) { | |
int returnSpot = text.LastIndexOf(" ", i); | |
if (returnSpot >= 0){ | |
text = text.Substring(0, returnSpot) + "\n" + text.Substring(returnSpot, text.Length-returnSpot); | |
i = returnSpot; | |
} | |
} | |
return text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment