private void PopulateFileList(string folderpath) { List <string> filenames = ReplUtils.GetSaveFileNames(folderpath); if (folderpath != CurrentFolderPath) { RemoveFileIcons(); for (int i = 0; i < filenames.Count; i++) { GameObject file = Instantiate(FileIcon, ItemsWindow.transform); var textcomponent = file.GetComponentInChildren <TMP_Text>(); textcomponent.text += filenames[i]; file.GetComponentInChildren <Button>().onClick.AddListener(delegate { IsReplayRun = true; Time.timeScale = speed; ReplayComponent.LoadReplay(Path.Combine(folderpath, textcomponent.text)); }); FileItems.Add(file); } CurrentFolderPath = folderpath; } else { ShowFileIcons(); } }