utniy untiyWebrequest加载本地音频

此处为加载mp3,需要加载其他格式可以修改AudioType

    private IEnumerator LoadFile2AudioClip_IE(string uri)//加载本地资源为声音
    {
        UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(uri,AudioType.MPEG);
        yield return request.SendWebRequest();
        
        AudioClip clip = DownloadHandlerAudioClip.GetContent(request);
        audioSource.clip = clip;
        audioSource.Play();
    }

你可能感兴趣的:(unity,untiyhttp,unity)