Check if GUI Label is full of text?

I have an image of an open book and a GUI Label over the top of each page which I plan to fill with text. Is there a way to check if the first label (the one over the left page) is full of text so I can make the rest of the text/string go to the next label?

If I need to add more info or code I can, just figured this was a question that’s pretty easy to understand. Thanks for any help

You can always check a GUILabel’s string’s number of characters with String.Length.

So you want to check if the Rectangle you use for the GUILabel is filled by the string. Here is a solution that should work:

Take the width of your Rectangle and use it to calculate which height the rectangle would have that would be needed to display the whole string:

float textRectHeight = GUI.skin.label.CalcHeight(yourString, widthOfLabel);

So if it’s height is bigger than your Label Rectangle’s height, then you now the string is too long to display on one page.

I guess you could then call a little function that just gradually decreases the number of characters in the string (via loop, again using CalcHeight) by taking them from the back and adding them to the end of a new string, and when the original Label Rectangle’s height is reached, you return the modified (shorter) original string to display on the first page, and also return the new string that haas all the rest of the original text.

Maybe there are better way but I think this one would work :slight_smile:

Edit: Here’s another link that might answer your question 2