I know, it's now about one year since this question was about one year ago, but if anyone finds this thread, I have another (I think much better) answer. When I created a quest system for a simple RPG, I also needed a List or array in buttons. I found out, that a 'List' and 'foreach' is a much easier way to do this so here is my code:
public List<Quest> activeQuests = new List<Quest> ();
public GameObject ButtonParent;
public GameObject ButtonCanvas;
void Update () {
if (Input.GetKeyDown(KeyCode.Q)) {
if (ButtonCanvas.activeInHierarchy) {
ButtonCanvas.SetActive(false);
} else {
ButtonCanvas.SetActive (true);
foreach (Quest currentQuest in activeQuests) {
GameObject currentButton = Instantiate (ButtonPrefab, ButtonCanvas.transform, false);
//use currentQuest for your GameObject like Array[i] in for
}
}
}
}