Exemple #1
0
 void Awake()
 {
     Instance     = this;
     mAudioSource = this.gameObject.AddComponent <AudioSource>();
     state        = new PlayerState();
     mode         = PlayMode.none;
 }
        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
        }