// Start is called before the first frame update void Start() { God god = GameObject.Find("God").GetComponent <God>(); SceneSwapper sceneSwapper = GameObject.Find("SceneSwapper").GetComponent <SceneSwapper>(); foreach (BoardData boardData in god.gameData.boards) { GameObject newButton = Instantiate(button, transform); newButton.GetComponentInChildren <Text>().text = boardData.boardName; newButton.GetComponent <Button>().onClick.AddListener(delegate { god.SetCurrentBoard(newButton.transform.GetSiblingIndex()); }); newButton.GetComponent <Button>().onClick.AddListener(delegate { sceneSwapper.GoToScene("Board"); }); } }
public void PopulateQuestions(CategoryData data) { int firstIndexOfQuestion = 0; foreach (Transform child in transform) { if (child.CompareTag("Question")) { child.GetComponent <Button>().onClick.AddListener(delegate { god.SetCurrentQuestion(data.questions[child.GetSiblingIndex() - firstIndexOfQuestion]); }); child.GetComponent <Button>().onClick.AddListener(delegate { if (GameObject.Find("God").GetComponent <God>().currentPlayMode == God.Mode.Edit) { GameObject.Find("Board").GetComponent <Board>().SaveBoard(); } ss.GoToScene("Question"); }); } else { firstIndexOfQuestion++; } } }