How do you search for GameObjects with tags and then add their names to a button?
A quick example.
void Start()
{
GameObject[] go = GameObject.FindGameObjectsWithTag("tag");
}
void OnGUI()
{
foreach(GameObject g in go)
{
if(GUILayout.Button(g.name))
{
DoSomething(g.name);
}
}
}
void DoSomething(string buttonName)
{
switch(buttonName)
{
case "Blue":
Debug.Log("The 'Blue' button was pressed");
break
case "Red":
Debug.Log("The 'Red' button was pressed");
break
}
}