如果出现这个报错
Errror:“Cannot connect to destination host.”
说明你的文件路径没有添加 "file://"
private IEnumerator LoadAudio(string filepath)
{
filepath = "file://" + filepath;
using (var uwr = UnityWebRequestMultimedia.GetAudioClip(filepath, AudioType.WAV))
{
yield return uwr.SendWebRequest();
if (uwr.isNetworkError)
{
Debug.LogError("------" + uwr.error);
}
else
{
AudioClip clip = DownloadHandlerAudioClip.GetContent(uwr);
CurAudioSource.clip = clip;
CurAudioSource.mute = false;
CurAudioSource.loop = false;
CurAudioSource.Play();
}
}
}