While loading sounds from a certain folder, I always get the error message:
Error: Cannot create FMOD::Sound instance for resource "qB, (Operation could not be performed because specified sound/DSP connection is not ready. )
UnityEngine.WWW:GetAudioClip(Boolean, Boolean, AudioType)
<LoadFiles>c__Iterator0:MoveNext() (at Assets/Scripts/LoadFolder.cs:38)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Linq;
public class LoadFolder : MonoBehaviour
{
public string PathString;
public SproutSoundList ListScript;
public AudioClip SproutSound;
void Start()
{
ListScript = GameObject.Find("ScriptCargo").GetComponent<SproutSoundList>();
}
public void StartLoading()
{
PathString = transform.parent.FindChild("Path").FindChild("PathDir").GetComponent<UnityEngine.UI.Text>().text;
PathString.Replace("\\", "/");
StartCoroutine("LoadFiles");
}
IEnumerator LoadFiles()
{
string Url = string.Format("file://{0}", PathString);
WWW www = new WWW(Url);
yield return www;
foreach (string File in Directory.GetFiles(PathString))
{
if (Path.GetFileName(File).Contains(".wav") || Path.GetFileName(File).Contains(".WAV"))
{
SproutSound = www.GetAudioClip(false, false, AudioType.WAV);
SproutSound.name = Path.GetFileName(File);
ListScript.SoundList.Add(SproutSound);
}
}
}
}
How to fix that??