示例#1
0
        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;
        }
示例#2
0
        public IEnumerator LoadImage(string filepath)
        {
            var popup = PopupLoading.Creat();

            yield return(new WaitForEndOfFrame());

            //WWW www = new WWW ("file://" + filepath);
            WWW www = new WWW(ConfigUtility.fileLoadPath(filepath));

            yield return(www);

            Destroy(popup);
            yield return(new WaitForEndOfFrame());

            try {
                if (ConfigUtility.isSupportedTextureType(Path.GetExtension(filepath)))
                {
                    editor.gameScreen.setBackgroundImage(www.texture);
                }
                else
                {
                    editor.debugLog.LogWarning(ExceptionList.openFileError.Value);
                    yield break;
                }
            } catch {
                editor.debugLog.LogWarning(ExceptionList.openFileError.Value);
                yield break;
            }
            editor.getTrackMap.header.BackgroundFileFullName = filepath;
            editor.debugLog.Log(MessageList.openFileSuccess.Value);
        }
示例#3
0
        IEnumerator _Init()
        {
            string path = null;

            path = ConfigUtility.fileLoadPath(
                Path.Combine(
                    temp.folderPath,
                    temp.chunkHeader.trackMapFileCode
                    )
                );

            WWW trackmap = new WWW(path);
            WWW texture  = null;

            path = Path.Combine(
                temp.folderPath,
                temp.chunkHeader.backgroundFileCode
                );

            bool hasTexture = File.Exists(path);

            path = ConfigUtility.fileLoadPath(path);

            if (hasTexture)
            {
                texture = new WWW(path);
            }

            yield return(trackmap);

            if (hasTexture)
            {
                yield return(texture);
            }


            trackMap = TrackMap.FromJson(trackmap.text);

            if (hasTexture)
            {
                m_Texture.mainTexture = texture.texture;
            }

            m_Label.text = trackMap.header.Title + " - " + trackMap.header.Artist;
            isInit       = true;
        }
示例#4
0
        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);
        }
        public IEnumerator LoadAudioCilp(string filepath)
        {
            var popup = PopupLoading.Creat();

            yield return(new WaitForEndOfFrame());

            WWW www = new WWW(ConfigUtility.fileLoadPath(filepath));

            yield return(www);

            Destroy(popup);
            yield return(new WaitForEndOfFrame());

            try {
                if (Path.GetExtension(filepath).ToLower() == ".mp3" && Application.platform != RuntimePlatform.Android)
                {
                    var clip = NAudioPlayer.FromMp3Data(www.bytes);
                    clip.name = Path.GetFileNameWithoutExtension(filepath);
                    editor.audioPlayer.SetClip(clip);
                }
                else if (Path.GetExtension(filepath).ToLower() == ".wav" ||
                         (Path.GetExtension(filepath).ToLower() == ".mp3" && Application.platform == RuntimePlatform.Android))
                {
                    var clip = www.audioClip;
                    clip.name = Path.GetFileNameWithoutExtension(filepath);
                    editor.audioPlayer.SetClip(clip);
                }
                else
                {
                    editor.debugLog.LogWarning(ExceptionList.openFileError.Value);
                    yield break;
                }
            } catch (Exception e) {
                editor.debugLog.LogWarning(ExceptionList.openFileError.Value);
                yield break;
            }
            editor.getTrackMap.header.AudioFileFullName = filepath;
            editor.debugLog.Log(MessageList.openFileSuccess.Value);
        }
        IEnumerator loadAudio()
        {
            var tmfOb = selector.getCurrentGameMapElement;

            string path = ConfigUtility.fileLoadPath(Path.Combine(tmfOb.temp.folderPath, tmfOb.temp.chunkHeader.audioFileCode));

            WWW www = new WWW(path);

            yield return(www);

            string audioExtension = Path.GetExtension(tmfOb.trackMap.header.AudioFileFullName);

            audioExtension = audioExtension.ToLower();

#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX
            if (audioExtension == ConfigUtility.Mp3Extension)
            {
                AudioClipPlayer.PlayAudioWithData(www.bytes);
            }
            else if (audioExtension == ConfigUtility.WavExtension)
            {
                var clip = www.GetAudioClip(true, false, AudioType.WAV);
                AudioClipPlayer.PlayAudio(clip);
            }
#else
            var clip = www.GetAudioClip(true, false, AudioType.MPEG);
            AudioClipPlayer.PlayAudio(clip);

            /*if(audioExtension == ConfigUtility.WavExtension){
             *      AudioClipPlayer.PlayAudioWithData(www.bytes);
             * }else if (audioExtension == ConfigUtility.Mp3Extension){
             *      var clip = www.GetAudioClip(true,false,AudioType.MPEG);
             *      AudioClipPlayer.PlayAudio(clip);
             * }*/
#endif
        }
示例#7
0
        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
        }