美文网首页
unity3D 使用WWW 加载网络上的Mp3

unity3D 使用WWW 加载网络上的Mp3

作者: 在夢里 | 来源:发表于2018-12-28 11:25 被阅读0次

public IEnumerator SendGet(string url)

    {

        WWW www = new WWW(url);

        yield return www;

        if (string.IsNullOrEmpty(www.error))

        {

            //GetComponent<AudioSource>().material.SetTexture("_MainTex", www.texture);

            GetComponent<AudioSource>().clip = www.GetAudioClip(true, true, AudioType.MPEG);

            GetComponent<AudioSource>().Play();

        }

    }

void Start()

    { string urlMusic = "http://fs.w.kugou.com/201812272129/79e6fa4013b917316b26c56f1180a60f/G127/M04/06/1B/vw0DAFwjaKmAVKRDADxB7o5uHSU509.mp3";

        StartCoroutine(SendGet(urlMusic));

 }

注意打成Apk,在移动端才有效

相关文章

网友评论

      本文标题:unity3D 使用WWW 加载网络上的Mp3

      本文链接:https://www.haomeiwen.com/subject/porslqtx.html