public void Awake() { songs = SongScanning.allSongs; if (songs == null) { UnityEngine.SceneManagement.SceneManager.LoadScene(0, UnityEngine.SceneManagement.LoadSceneMode.Single); return; } fade.color = new Color(0, 0, 0, 1); StartCoroutine(FadeOutStart()); selectScreen.SetActive(true); for (int i = 0; i < songs.Count; ++i) { SongBlock newBlock = Instantiate(songblockPrefab.gameObject).GetComponent <SongBlock>(); newBlock.transform.SetParent(songblockPrefab.transform.parent); newBlock.transform.localPosition = Vector3.zero; newBlock.transform.localScale = Vector3.one; newBlock.text.text = songs[i].displayArtist; newBlock.fileInfo = songs[i].fileInfo; } if (songs.Count == 0) { songblockPrefab.text.text = "No Songs found"; songblockPrefab.GetComponent <Button>().enabled = false; } else { songblockPrefab.gameObject.SetActive(false); } }
public void Awake() { AudioObjects = NonStaticAudioObjects; songs = SongScanning.allSongs; if (songs == null) { UnityEngine.SceneManagement.SceneManager.LoadScene(0, UnityEngine.SceneManagement.LoadSceneMode.Single); return; } fade.color = new Color(0, 0, 0, 1); StartCoroutine(FadeOutStart()); selectScreen.SetActive(true); for (int i = 0; i < songs.Count; ++i) { SongBlock newBlock = Instantiate(songblockPrefab.gameObject).GetComponent <SongBlock>(); newBlock.transform.SetParent(songblockPrefab.transform.parent); newBlock.transform.localPosition = Vector3.zero; newBlock.transform.localScale = Vector3.one; newBlock.Artist.text = songs[i].Artist; newBlock.SongName.text = songs[i].SongName; newBlock.Charter.text = songs[i].Charter; newBlock.ChartLocation = songs[i].fileLoction; newBlock.type = songs[i].type; newBlock.name = songs[i].SongName; string path = Path.GetDirectoryName(songs[i].fileLoction); string[] pngFiles = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories); if (pngFiles.Length > 0) { StartCoroutine(SongLoader.Instance.GetImage(newBlock.CoverImage, pngFiles[0])); } } if (songs.Count == 0) { songblockPrefab.SongName.text = "No Songs found"; songblockPrefab.GetComponent <Button>().enabled = false; } else { songblockPrefab.gameObject.SetActive(false); } }