- Home /
Make a Button For Every String in an Array of Level Names
Alright guys, so here's my question, how could I make a GUI Button that would load the respective level in an array for every element in that array? Here is my code at the moment:
var skin : GUISkin; var levelGUINames : String[]; var levelSceneNames : String[]; var i : int;
 
               function OnGUI () { GUI.skin = skin; GUILayout.BeginArea(Rect(Screen.width / 2 - 350, Screen.height / 2 - 200, 700, 700)); GUILayout.Box("Level Select");
 for(var str : String in levelGUINames) {
  if (GUILayout.Button(str))
     {
         Application.LoadLevel(levelSceneNames[i]);
     }
 i++;
 } 
 GUILayout.EndArea(); 
}
Answer by Eric5h5 · Mar 26, 2011 at 08:09 PM
Instead of for/in, do
for (i = 0; i < levelGUINames.Length; i++)
Your answer
 
 
             Follow this Question
Related Questions
Cycle Through Array of Enemies 1 Answer
[SOLVED]Object selection scrip doesn't work. 2 Answers
Determining groups in a 2D array by checking neighbours (and their neighbours etc) 2 Answers
How to create an image gallery with previous and next button with C#? 6 Answers
Has anyone ever used code to change the materials on an instantiated game object? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                