- Home /
 
               Best Answer 
              
 
              Answer by Scribe · Jun 08, 2013 at 11:49 PM
I made this a while ago, not sure its particularly efficient but it appears to do the job!
 var myString : String;
 private var tempString : String;
 private var stringSize : Vector2;
 var labelWidth = 100;
 
 function Start () {
     if(labelWidth < 15){
         labelWidth = 15;
     }
 }
 
 function OnGUI () {
     myString = GUI.TextField(Rect(10, 10, 300, 20), myString);
     stringSize = GUI.skin.GetStyle("Box").CalcSize(GUIContent(myString));
     
     if(stringSize.x > labelWidth){
         CalcSubstring();
         GUI.Label(Rect(10, 40, labelWidth, 20), tempString + "...");
     }else{
         GUI.Label(Rect(10, 40, labelWidth, 20), myString);
     }
 }
 
 function CalcSubstring () {
     tempString = myString;
     while(GUI.skin.GetStyle("Box").CalcSize(GUIContent(tempString)).x > labelWidth-8){
         tempString = tempString.Substring(0, tempString.Length - 1);
     }
 }
Scribe
P.S
please include a description of your problem in future
Your answer
 
 
             Follow this Question
Related Questions
gui text button dont work 1 Answer
Editing certain words in a single NGUI Text Box 0 Answers
Fix Blurry UI text? 10 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                