Sensing if a string is multi - lined

Hi, all! I am creating a conversation system, and it is going along quite well. I was wondering if anyone knew how to sense if a string is longer than the space it is contained in. I have a box that is high enough for one line of text across it, and if the string is too long, it runs off the box. I need to make a script that checks to see if the supplied string is longer than x amount of characters, and if so, pop an old school scrollbar on there. I’m pretty sure I can achieve the scroll bar with two buttons and a GUI group, but I would like to know how to sense if a string is multi-lined.

Some images if I’m not being clear here. the first is text that fits, and the second is text that doesn’t.

alt text
alt text

Maybe you could use GUIStyle.calcSize? to figure out how large space the text with a given style need? And the scrollbar can be automatic with GUI.BeginScrollView. That is, if you use UnityGUI…

you can get the length of the string using “Length” property

it works like stringName.Lenghth;

u can calculate the number of character that can contain in the bar using its width and height along with the the size of the font you are using!

so just compare it and u would get what you want!!