public void ShowLoadScreen() { GetLoadFiles(); foreach (Transform button in loadArea) { Destroy(button.gameObject); } for (int i = 0; i < saveFiles.Length; i++) { GameObject buttonObject = Instantiate(loadButtonPrefab); buttonObject.transform.SetParent(loadArea.transform, false); var index = i; buttonObject.transform.GetChild(0).GetComponent <Button>().onClick.AddListener(() => { OnLoad(saveFiles[index]); FindObjectOfType <MenuStateManager>().StartGamePage(); }); buttonObject.transform.GetChild(1).GetComponent <Button>().onClick.AddListener(() => { SerializationManager.Delete(saveFiles[index]); ShowLoadScreen(); }); buttonObject.transform.GetChild(0).GetChild(0).GetComponentInChildren <TextMeshProUGUI>().text = saveFiles[index].Replace(Application.persistentDataPath + "/saves/", ""); } }