Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

How can I load an AudioClip from a local audio file using UnityWebRequests?

$
0
0
I'm trying to make a rhythm game which allows for creation of custom levels. To accomplish this, I need to be able to load audio files from local folders. I can't use the Resources folder because the user needs to be able to provide the song file themselves during level development. I've been using the following method: string songPath = "C:\Users\...\levels\[level name]\song.ogg" using (var www = new WWW("file:///" + songPath)) { yield return www; song = www.GetAudioClip(); } audioSource.clip = song; It's been working well, but the console gives me a warning saying that WWW is obsolete, and I should be using UnityWebRequests. I'd like to, to futureproof my game, but I can't figure out how to do it. How can I use UnityWebRequests to extract an AudioClip from a local audio file?

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>