IEnumerator LoadTexture(GameMapTempFolder temp) { string path = Path.Combine( temp.folderPath, temp.chunkHeader.backgroundFileCode ); bool hasTexture = File.Exists(path); if (!hasTexture) { yield break; } path = ConfigUtility.fileLoadPath(path); WWW texture = new WWW(path); //yield return texture; while (!texture.isDone) { GameLoadingDialog.getInstance.ReportProgress(0.66f + texture.progress / 3f); yield return(null); } if (!string.IsNullOrEmpty(texture.error)) { Debug.LogError("Temp Folder texture Error : " + texture.error); } backgorundImage.mainTexture = texture.texture; }
/// <summary> /// Loads the temps. /// 載入暫時檔案資料 /// </summary> private void LoadTemps() { //Debug.Log("暫存路徑" + ConfigUtility.temporaryPath); DirectoryInfo directory = new DirectoryInfo(ConfigUtility.temporaryPath); DirectoryInfo[] directoryInfos = directory.GetDirectories(); //Debug.Log("數量:" + directoryInfos.Length); foreach (var directoryInfo in directoryInfos) { //Debug.Log("載入暫存" + directoryInfo.Name); if (GameMapTempFolder.isTempFolder(directoryInfo.FullName)) { string fullPath = directoryInfo.FullName; GameMapTempFolderPaths.Add(fullPath); GameMapTempFolders.Add(new GameMapTempFolder(fullPath)); } } }
IEnumerator LoadTrackMap(GameMapTempFolder temp) { string path = ConfigUtility.fileLoadPath( Path.Combine( temp.folderPath, temp.chunkHeader.trackMapFileCode ) ); WWW trackmap = new WWW(path); //yield return trackmap; while (!trackmap.isDone) { GameLoadingDialog.getInstance.ReportProgress(trackmap.progress / 3f); yield return(null); } currentTrackMap = TrackMap.FromJson(trackmap.text); }
/// <summary> /// Loads the files. /// 載入歌譜 /// 並生成暫時檔案資料 /// </summary> private void LoadFiles() { //Debug.Log("檔案路徑" + ConfigUtility.persistentDataPath); DirectoryInfo directory = new DirectoryInfo(ConfigUtility.persistentDataPath); FileInfo[] fileInfos = directory.GetFiles("*" + GameMap.extension); //Debug.Log("數量:" + fileInfos.Length); foreach (var fileInfo in fileInfos) { Debug.Log(fileInfo.Name); if (!GameMapTempFolder.hasTempFolder(fileInfo.FullName)) { //Debug.Log("生成暫存" + fileInfo.Name); //GameMap trackMapFile = new GameMap(fileInfo.FullName); GameMap trackMapFile = GameMapUtility.GenerateGameMap(fileInfo.FullName); GameMapTempFolder temp = new GameMapTempFolder(trackMapFile); temp.GenerateFolder(trackMapFile); GameMapTempFolderPaths.Add(temp.folderPath); GameMapTempFolders.Add(temp); } } }
IEnumerator LoadByTemp() { GameLoadingDialog.getInstance.Open(); GameMapTempFolder temp = new GameMapTempFolder(currentGameMapCache.filePath); string path = null; WWW texture = null; //trackMap yield return(StartCoroutine(LoadTrackMap(temp))); GenerateNotes(); isGenerated = true; audioPlayer.Stop(); //audio yield return(StartCoroutine(LoadAudioClip(temp))); audioPlayer.Stop(); //texture yield return(StartCoroutine(LoadTexture(temp))); print("|GenerateNotes|"); GameLoadingDialog.getInstance.Close(); countDown.StartCountDown(); yield return(new WaitUntil(() => { return countDown.isDone; })); audioPlayer.Play(); isPrepare = true; }
IEnumerator LoadAudioClip(GameMapTempFolder temp) { string path = Path.Combine( temp.folderPath, temp.chunkHeader.audioFileCode ); bool hasAudio = File.Exists(path); if (!hasAudio) { Debug.LogError("Temp Folder Audio Is Not Exists"); } path = ConfigUtility.fileLoadPath(path); WWW clip = new WWW(path); //yield return clip; while (!clip.isDone) { GameLoadingDialog.getInstance.ReportProgress(0.33f + clip.progress / 3f); yield return(null); } if (!string.IsNullOrEmpty(clip.error)) { Debug.LogError("Temp Folder Audio Error : " + clip.error); } string extension = Path.GetExtension(currentTrackMap.header.AudioFileFullName); extension = extension.ToLower(); #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX if (extension.CompareTo(ConfigUtility.WavExtension) == 0) { audioPlayer.SetClip(clip.GetAudioClip(true, false, AudioType.WAV)); //audioPlayer.Play(); } else if (extension.CompareTo(ConfigUtility.Mp3Extension) == 0) { audioPlayer.SetClip(NAudioPlayer.FromMp3Data(clip.bytes)); //audioPlayer.Play(); } else { Debug.LogError("無法辨識副檔名:" + extension); hasAudio = false; } #else if (extension.CompareTo(ConfigUtility.WavExtension) == 0) { audioPlayer.SetClip(clip.GetAudioClip(true, false, AudioType.WAV)); audioPlayer.Play(); } else if (extension.CompareTo(ConfigUtility.Mp3Extension) == 0) { audioPlayer.SetClip(clip.GetAudioClip(true, false, AudioType.MPEG)); audioPlayer.Play(); } else { Debug.LogError("無法辨識副檔名:" + extension); hasAudio = false; } #endif }
public void Init(GameMapTempFolder _temp) { temp = _temp; StartCoroutine(_Init()); }