当前位置: 首页>>代码示例>>C#>>正文


C# WWW.GetAudioClip方法代码示例

本文整理汇总了C#中UnityEngine.WWW.GetAudioClip方法的典型用法代码示例。如果您正苦于以下问题:C# WWW.GetAudioClip方法的具体用法?C# WWW.GetAudioClip怎么用?C# WWW.GetAudioClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.WWW的用法示例。


在下文中一共展示了WWW.GetAudioClip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DownloadAudio

    private IEnumerator DownloadAudio()
    {
        _url = input_url.text;

        //#if !UNITY_EDITOR
        //	_url = _url.Replace("http://www.spilldemo.com", Application.dataPath + "/..");
        //#endif

        Debug.Log("_url: " + _url);

        yield return new WaitForSeconds(0.5f);

        WWW www = new WWW(_url);
        yield return www;

        string extension = _url.Substring(_url.Length - 4);
        Debug.Log("extension: " + extension);

        if (extension.Equals(".ogg"))
            _source.clip = www.GetAudioClip(false, false, AudioType.OGGVORBIS);
        else if (extension.Equals(".mp3"))
            _source.clip = www.GetAudioClip(false, false, AudioType.MPEG);
        else if (extension.Equals(".wav"))
            _source.clip = www.GetAudioClip(false, false, AudioType.WAV);
        else
            _source.clip = www.GetAudioClip(false, false, AudioType.UNKNOWN);

        yield return new WaitForSeconds(0.5f);

        _source.Play();
    }
开发者ID:piter65,项目名称:spilldec,代码行数:31,代码来源:test_dynamic_audio.cs

示例2: onFlightStart

    protected override void onFlightStart()
    {
        ping = gameObject.AddComponent<AudioSource>();
        WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MuonDetector/ping.wav");
        if ((ping != null) && (www != null))
        {
            ping.clip = www.GetAudioClip(false);
            ping.volume = 0;
            ping.Stop();
        }

        disk = transform.Find("model/disk");
        if (disk != null)
        {
            MIN_PING_DIST = 150000;
            MIN_PING_TIME = 0.2;
            MAX_PING_TIME = 15;

            led = transform.Find("model/led");
            originalLensShader = led.renderer.material.shader;
            pingLight = led.gameObject.AddComponent<Light>();
            pingLight.type = LightType.Point;
            pingLight.renderMode = LightRenderMode.ForcePixel;
            pingLight.shadows = LightShadows.None;
            pingLight.range = 1;
            pingLight.enabled = false;
        }

        RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
    }
开发者ID:Majiir,项目名称:MuMechLib,代码行数:30,代码来源:MuonDetector.cs

示例3: StartLoadMusic

    private IEnumerator StartLoadMusic(string url, bool broadcast = false)
    {
        var s = http + "://tmrace.net/cops/music.php?url=" + WWW.EscapeURL(url);
        Debug.LogWarning(s);
        var w = new WWW(s);
        yield return w;
        if(string.IsNullOrEmpty(w.text))yield break;
        print(w.text);
        w = new WWW(w.text);
        yield return w;
        var audioClip = w.GetAudioClip(false, true, AudioType.OGGVORBIS);
        if (audioClip.length == 0)
        {
            Debug.LogError(w.error);
            yield break;
        }
        if (broadcast && _Game && audioClip)
        {
            broadCastTime = Time.time;
            _GameGui.CallRPC(_GameGui.Chat, _Loader.playerName + " Play music " + Path.GetFileNameWithoutExtension(w.url));
            _GameGui.CallRPCTo(_MpGame.LoadMusic, PhotonTargets.Others, s);
        }

        audio.clip = audioClip;
        audio.Play();
    }
开发者ID:friuns,项目名称:New-Unity-Project-tm2---Copy,代码行数:26,代码来源:Music.cs

示例4: FileSelected

    protected void FileSelected(string path)
    {
        fileBrowser = null;

        if (path != null)
        {
            Debug.Log(path);
            if(path.Contains(".mp3"))
            {
                Debug.Log(path);
                using (Mp3FileReader reader = new Mp3FileReader(path))
                {
                    Debug.Log("Reached");
                    path = path.Replace(".mp3", ".wav");
                    WaveFileWriter.CreateWaveFile(path , reader);
                }
            }
            path = "file://" + path;
            WWW wtf = new WWW(path);

            //Wait for wtf to finish
            while (!wtf.isDone)
            {
            }
            SceneManager.getInstance.setClip(wtf.GetAudioClip(false));
        }
    }
开发者ID:NickCellino,项目名称:RiftMusicVisualizer,代码行数:27,代码来源:UIManagerScript.cs

示例5: StartLoadMusic

    private IEnumerator StartLoadMusic(string url, bool broadcast = false)
    {
        var s = http + "//tmrace.net/cops/music.php?url=" + WWW.EscapeURL(url);
        print(s);
        var w = new WWW(s);
        yield return w;
        print(w.text);
        w = new WWW(w.text);
        yield return w;
        var audioClip = w.GetAudioClip(false, true);
        if (audioClip.length == 0)
        {
            Debug.LogError(w.error);
            yield break;
        }
        if (broadcast && _Game && audioClip)
        {
            broadCastTime = Time.time;
            _Game.CallRPC(_ChatGui.Chat, _Player.playerName + " Set music to " + w.text);
            _Game.CallRPCTo(_Game.LoadMusic, PhotonTargets.Others, w.text);
        }

        audio.clip = audioClip;
        audio.Play();
    }
开发者ID:friuns,项目名称:New-Unity-Project-Eddy-Car-Phys,代码行数:25,代码来源:LoaderMusic.cs

示例6: OpenAndPlay

 private IEnumerator OpenAndPlay(string path)
 {
     WWW www = new WWW("file://" + path);
     this.AudioSource.clip = www.GetAudioClip(false, true);
     while (this.AudioSource.clip.isReadyToPlay == false) yield return null;
     this.AudioSource.Play();
 }
开发者ID:Kaiymu,项目名称:RyS,代码行数:7,代码来源:MusicManager.cs

示例7: GetAudioClip

 public AudioClip GetAudioClip()
 {
     var thewww = new WWW(song);
     while(!thewww.isDone){ }
     var ac = thewww.GetAudioClip(false, true,AudioType.OGGVORBIS);
     thewww.Dispose();
     return ac;
 }
开发者ID:BenouKat,项目名称:Unity-ITGHD,代码行数:8,代码来源:Song.cs

示例8: LoadMusic

 IEnumerator LoadMusic(string[] urls)
 {
     foreach (string url in urls){
         WWW download = new WWW ("file://" + url);
         yield return download;
         music.Add(download.GetAudioClip(false));
     }
 }
开发者ID:kiichi7,项目名称:ZombieShoot,代码行数:8,代码来源:MusicPlayer.cs

示例9: LoadClip

 public static IEnumerator LoadClip(AudioSource audioSource)
 {
     WWW www = new WWW("file://" + tempFolder + "output.wav");
     while (!www.isDone)
         yield return www;
     AudioClip clip = www.GetAudioClip(false);
     audioSource.clip = clip;
     if (clip.length > 0)
         audioSource.PlayDelayed(0.02f);
 }
开发者ID:RuslanAhmetsharipov,项目名称:TalkingHead,代码行数:10,代码来源:AnimationController.cs

示例10: LoadSound

    private IEnumerator LoadSound()
    {
        WWW www = new WWW("File://" + Application.streamingAssetsPath + "/Audio/buttonSound.ogg");
        yield return www;

        //buttonSound = www.audioClip;
        buttonSound = www.GetAudioClip(false);

        www.Dispose();
    }
开发者ID:ImL1s,项目名称:YsUGUI-Extension,代码行数:10,代码来源:ButtonSoundUGUI.cs

示例11: GetWWW

    IEnumerator GetWWW(int st)
    {
        www = new WWW(urls[st]);
        int frames = 0;
        while (www != null && !www.isDone)
        {
            m_info = "Loading... " + frames;
            frames++;
            yield return new WaitForEndOfFrame();
        }

        if (!string.IsNullOrEmpty(www.error))
        {
            m_info = "Error: " + www.error;
        }
        else
        {
            m_info = "Done!";
            switch (st)
            {
                case 0:
                    {
                        m_info += " Press Mouse Button 2 to load texture";
                        tex = null;
                        if (www.audioClip != null)
                        {
                            _audio = www.GetAudioClip(false, false, AudioType.WAV);
                            if (_audio == null)
                                yield return new WaitForEndOfFrame();
                            else
                                gameObject.GetComponent<AudioSource>().clip = _audio;
                        }
                        break;
                    }
                case 1:
                    {
                        m_info += " Press Mouse Button 2 to load texture (non readable) and load into texture";
                        _audio = null;
                        gameObject.GetComponent<AudioSource>().clip = null;
                        if (www.texture != null)
                            tex = www.texture;
                    }
                    break;
                case 2:
                    {
                        m_info += " Press Mouse Button 2 to load sound";
                        if (www.textureNonReadable != null)
                            www.LoadImageIntoTexture(tex);

                    }
                    break;
            }
        }
    }
开发者ID:stella3d,项目名称:gridtastic,代码行数:54,代码来源:WWWScript_assets.cs

示例12: start

 IEnumerator start()
 {
     // Remove the "spaces" in excess
     Regex rgx = new Regex ("\\s+");
     // Replace the "spaces" with "% 20" for the link Can be interpreted
     string result = rgx.Replace ("Hello", "%20");
     string url = "http://translate.google.com/translate_tts?tl=en&q=" + result;
     WWW www = new WWW (url);
     yield return www;
     GetComponent<AudioSource>().clip = www.GetAudioClip (false, false, AudioType.MPEG);
     GetComponent<AudioSource>().Play ();
 }
开发者ID:Jeffreywoot,项目名称:VIsualNovel,代码行数:12,代码来源:Dialogue.cs

示例13: play

 public void play()
 {
     //the actual play button activation method
     string fullpath = "file://" + fileinfo [selectedCellIndex].FullName;
     Debug.Log ("Play, " + fullpath);
     WWW clip = new WWW (fullpath);
     Debug.Log (clip.bytes);
     audioSource.clip = clip.GetAudioClip (false, true);
     audioSource.Play ();
     //Animation Anime = jeep.GetComponent<Animation> ();
     //Anime.Play ("Take 001");
     //Debug.Log (Anime.Play ());
 }
开发者ID:CaminhoneiroHell,项目名称:demo_cardboard,代码行数:13,代码来源:FileTableViewController.cs

示例14: DownloadSound

    IEnumerator DownloadSound()
    {
        WWW www = new WWW("http://7ROAD-20140625X.7road.com/music.wav");
        yield return www;

        if (www.error != null)
        {
            m_info = www.error;
            yield return null;
        }
        m_downloadClip = www.GetAudioClip(false);
        audio.PlayOneShot(m_downloadClip);
    }
开发者ID:hcyxt,项目名称:www,代码行数:13,代码来源:WebManager.cs

示例15: download

    IEnumerator download(string filePathUrl)
    {
        WWW www = new WWW (filePathUrl);

        while (!www.isDone) { // ダウンロードの進捗を表示
            print (Mathf.CeilToInt (www.progress * 100));
            yield return null;
        }

        if (!string.IsNullOrEmpty (www.error)) { // ダウンロードでエラーが発生した
            Debug.Log ("error:" + www.error);
        } else { // ダウンロードが正常に完了した
            filePath = Application.persistentDataPath + "/" + Path.GetFileName (www.url);
            File.WriteAllBytes (filePath, www.bytes);
            Debug.Log ("download file write success." + filePath);
            audioSource.clip = www.GetAudioClip(false, true, AudioType.MPEG);
            audioSource.Play();
            // 音声の時間を保存しておく
            maxAudioTime = www.GetAudioClip(false, true, AudioType.MPEG).length;
            audioTime = maxAudioTime;
        }
    }
开发者ID:rabbit-club,项目名称:hd2016-unity,代码行数:22,代码来源:MainController.cs


注:本文中的UnityEngine.WWW.GetAudioClip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。