private void LoadModule3() { module3MapButtons.ForEach(item => Destroy(item)); module3MapButtons.Clear(); string[] allAvailableMaps = MapEditor.GetAllMapsPaths(); for (int i = 0; i < allAvailableMaps.Length; i++) { Vector3 pos = new Vector3(4f, 9.7f - (i * 0.6f), 0f); GameObject newBtn = Instantiate(module3MapButton); newBtn.transform.SetParent(module3.transform); newBtn.transform.localPosition = pos; newBtn.transform.rotation = Quaternion.identity; newBtn.transform.GetChild(3).GetComponent <TextMeshPro>().text = Path.GetFileName(allAvailableMaps[i]); newBtn.transform.GetChild(4).GetComponent <TextMeshPro>().text = File.GetLastAccessTime(allAvailableMaps[i]).ToString(); string path = MapEditor.PathToMapsDir + "/" + newBtn.transform.GetChild(1).transform.parent.GetChild(3).GetComponent <TextMeshPro>().text; newBtn.transform.GetChild(1).GetComponent <Button3D>().OnClick.AddListener((sender) => { StartCoroutine(Coroutine()); IEnumerator Coroutine() { camAnim.SetInteger("view", LEVEL); camAnim.SetTrigger("switch"); yield return(new WaitForSeconds(0.5f)); module3.SetActive(false); camAnim.enabled = false; MapSerializer serializer = new MapSerializer(path); Map deserializedMap = serializer.Deserialize(false); mapEditor.InitializeEditor(deserializedMap, path); } }); newBtn.transform.GetChild(0).GetComponent <Button3D>().OnClick.AddListener((sender) => { MapSerializer serializer = new MapSerializer(path); Map deserializedMap = serializer.Deserialize(false); module3.SetActive(false); module2Info.SetActive(true); RankingManager.Record[] records = RankingManager.GetRecords(deserializedMap.name); TextMeshPro text = module2Info.transform.GetChild(2).GetComponent <TextMeshPro>(); text.text = ""; foreach (RankingManager.Record r in records) { text.text += $"Points: <b>{r.points.ToString()} | </b>Count of moves: <b>{r.moves.ToString()}</b> | Date: <b>{r.date.ToShortDateString()} {r.date.ToShortTimeString()}</b>\n"; } SetMapIcon(path, module2Info.transform.GetChild(0).gameObject); Button3D playBtn = module2Info.transform.GetChild(4).GetComponent <Button3D>(); Button3D playSavedBtn = module2Info.transform.GetChild(5).GetComponent <Button3D>(); playSavedBtn.isClickable = SaveLoadManager.SaveExists(deserializedMap); playSavedBtn.OnClick.RemoveAllListeners(); if (playSavedBtn.isClickable) { playSavedBtn.OnClick.AddListener(s => { Map progressedMap = SaveLoadManager.LoadLevelProgress(deserializedMap, out int movesCount); StartCoroutine(Coroutine()); IEnumerator Coroutine() { camAnim.SetInteger("view", LEVEL); camAnim.SetTrigger("switch"); yield return(new WaitForSeconds(0.5f)); module3.SetActive(false); module2Info.SetActive(false); camAnim.enabled = false; LevelManager.CurrentManager.SetBackgroundColor(progressedMap.biomeType); LevelManager.CurrentManager.LoadLevel(progressedMap, movesCount); } }); } playBtn.OnClick.RemoveAllListeners(); playBtn.OnClick.AddListener(s => { SaveLoadManager.ClearSave(deserializedMap); StartCoroutine(Coroutine()); IEnumerator Coroutine() { camAnim.SetInteger("view", LEVEL); camAnim.SetTrigger("switch"); yield return(new WaitForSeconds(0.5f)); module3.SetActive(false); module2Info.SetActive(false); camAnim.enabled = false; LevelManager.CurrentManager.SetBackgroundColor(deserializedMap.biomeType); LevelManager.CurrentManager.LoadLevel(deserializedMap); } }); }); newBtn.transform.GetChild(2).GetComponent <Button3D>().OnClick.AddListener((sender) => { File.Delete(MapEditor.PathToMapsDir + "/" + sender.transform.parent.GetChild(3).GetComponent <TextMeshPro>().text); LoadModule3(); }); module3MapButtons.Add(newBtn); } }