- Home /
 
               Question by 
               eddyjohnson3 · Jul 03, 2012 at 12:54 PM · 
                guitextscrollingvertical  
              
 
              vertical scrolling, non editable text area.
Hi I am trying to create a vertically scrolling text area help section for android. I am using the GUILayout.BeginScrollView and a Label for text, but the problem is, I only get horizontal scrolling. Is there a way I can force the text to actually break in lines nicely, so the user can scroll it vertically, and it would adapt to different scren sizes? Here is the code:
     GUILayout.BeginArea (Rect(50, 50, Screen.width-100, Screen.height-50));
  
  scrollPosition = GUILayout.BeginScrollView (scrollPosition, GUILayout.Width (Screen.width-100), GUILayout.Height (Screen.height-100));
  
  GUILayout.Label(rulesText, smallText);
  
  GUILayout.EndScrollView ();
  
  GUILayout.EndArea();
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by flamy · Jul 03, 2012 at 01:40 PM
you have to use a box with word wrap on to get this output. In default Gui style wordwrap will be off.
  GUILayout.BeginArea (Rect(50, 50, Screen.width-100, Screen.height-50));
  scrollPosition = GUILayout.BeginScrollView (scrollPosition, GUILayout.Width (Screen.width-100), GUILayout.Height (Screen.height-100));
   /*changes made in the below 2 lines */
  GUI.skin.box.wordWrap = true;     // set the wordwrap on for box only.
  GUILayout.Box(rulesText);        // just your message as parameter.
 
  GUILayout.EndScrollView ();
 
  GUILayout.EndArea();
thanks for answer , how to remove the black background ?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                