- Home /
 
Automatic Wrap
Hi all, I generates the buttons in a loop. I would like the buttons that automatically put a newline. But I do not know how ...
 The code (example):
 private void flapWindow(int ID){
 
 GUILayout.BeginHorizontal()
 
 foreach(KeyValuePair<string, Vector3> kvp in goToPos){
 
     if( GUILayout.Button(kvp.Key))goTo(kvp.Value);
 
 }
 
 GUILayout.EndHorizontal();
 
 }
 
               The problem is that the window expands in width but the text is not to new line ...strong text
Answer by AlucardJay · Aug 19, 2012 at 04:45 PM
At a guess, you need to begin and end groups within your foreach loop :
 private void flapWindow(int ID){
 
     foreach(KeyValuePair<string, Vector3> kvp in goToPos)
     {
         GUILayout.BeginHorizontal();
         if( GUILayout.Button(kvp.Key))goTo(kvp.Value);
         GUILayout.EndHorizontal();
     }
 }
 
              Answer by laurent-clave · Aug 19, 2012 at 02:48 PM
little up ?
Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base. Also, this now shows in the list as having one answer, so you'll have less chance of getting an actual answer =]
I'm not familiar with GUI commands or C# but check my answer ($$anonymous$$ $$anonymous$$ay)
Your answer
 
             Follow this Question
Related Questions
"Organic" GUI Layout C# 3 Answers
gui text button dont work 1 Answer
GUI click through? 3 Answers
Button onClick events will not be triggered 1 Answer
know GUILayout current screen position 2 Answers