- Home /
Create a series of buttons out of the names of a object childs names.
Hi all,
I hope the way I am describing this makes sense . I have a project with a 3d Model in it. This model is imported from 3dsmax and has a lot of child objects, with unique names. What I would like to do is to create a script that reads out all of these child object names, and create a series of buttons for each name. The object names should appear on text on these button. Now the last part of this I have no idea how to start with this code.
I have a piece of script which gets the names from the 3d model object. And I know how to write them to the debug log with . I tried writing the contents to a guitext also but only the very last name appears. Can somebody help me out?
void Start()
{
WithForeachLoop();
WithForLoop();
}
void WithForeachLoop()
{
foreach (Transform child in transform)
print("Foreach loop: " + child);
//textfield = ("\n" + Transform child in transform);
}
void WithForLoop()
{
int children = transform.childCount;
for (int i = 0; i < children; ++i)
//Debug.Log("For loop: " + transform.GetChild(i));
my_text.text = (textfield);
}
Comment