示例#1
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);
        }
        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);
        }