- Home /
Question by
AKhilles47 · Mar 20, 2014 at 12:55 AM ·
buttonloopbuttons
Making buttons by clicking one button
I am trying to make multiple buttons after clicking one button aka click a folder and the folder's subfolders pop up, but the program will not bring up the other buttons after I click the folder button. If I comment out the folder button creation aka the if statement around creating the other buttons, the other buttons initialize fine. I do not know why this is happening.
The segment of the code involving the problem is below and thank you for the help. Please Help
if (GUI.Button ( new Rect(0,40,100,40),folderName))
{
string[] subDirectories = Directory.GetDirectories(curPath);
int count = 0;
float yOffset = .0f;
foreach(string curSubPath in subDirectories)
{
print ("here evan told me to write something ");
makeEvolutionSubMenu(curSubPath,count,yOffset);
yOffset = yOffset + .12f;
count = count + 1;
}
}
}
}
void makeEvolutionSubMenu(string curSubPath,int count,float yOffset)
{
List<string> subFolderNameList = new List<string>();
int n = curSubPath.Length - 1;
string subFolderName = "";
char d = ' ';
do{
subFolderName = d + subFolderName;
d = curSubPath[n];
n--;
} while (d !='/');
print (subFolderName);
subFolderNameList.Add (subFolderName);
if (GUI.Button ( new Rect(210,30+(count*50)/*Screen.height*.05f + yOffset*/,Screen.width*.1f,Screen.height*.07f),subFolderName))//GUI.Button (new Rect (Screen.width*.0f,Screen.height*(.0f+yOffset),Screen.width*.31f,Screen.height*(.30f+yOffset)),subFolderName))
{
print (subFolderName);
}
}
Comment
Your answer
Follow this Question
Related Questions
How to detect a button being released? 1 Answer
How to create a button and delay it 0 Answers
Pause menu not working 1 Answer
Where is my OnClick in the button script? 1 Answer
How to change button text via script? 2 Answers