What I found online says that the below code should work, even tho I'm on Unity 2022. But I get "System.MissingMethodException: Method not found: 'Void UnityEngine.Networking.DownloadHandlerAudioClip..ctor(System.String, UnityEngine.AudioType)' "
private static IEnumerator StartPlay(string path, float volume = 1f, float pitch = 1f)
{
var www = UnityWebRequestMultimedia.GetAudioClip($"file://{path}", AudioType.WAV);
yield return www.SendWebRequest();
AudioClip audioClip;
if (audioCache.ContainsKey(path))
audioClip = audioCache[path];
else
if (www.result == UnityWebRequest.Result.Success)
{
audioClip = DownloadHandlerAudioClip.GetContent(www);
audioCache[path] = audioClip;
}
else
{
Logger.Error($"Failed to load audio clip: {www.error}", "CustomSounds.LoadAudioClip");
yield break;
}
if (audioClip != null)
{
var source = SoundManager.Instance.PlaySoundImmediate(audioClip, false, volume, pitch);
UnityEngine.Object.Destroy(source, audioClip.length + 0.1f);
}
}