- Home /
Loading multiple audios from FILE during EDITOR MODE
Hi guys, I am trying to improve my audio manager by instead of dragging audio clip 1 by 1 into the manager. User can press a button in the editor and load all the files from a directory and assign them into a list or array.
So far I have gotten: - a GUILayout.Button (for purpose of calling the function that reloads the audio manager once) which calls :
public void ReloadSounds()
{
print ("Reload Pressed");
clips.Clear();
// get all valid files
var info = new DirectoryInfo(absolutePath);
soundFiles = info.GetFiles()
.Where(f => IsValidFileType(f.Name))
.ToArray();
// and load them
foreach (var s in soundFiles)
StartCoroutine(LoadFile(s.FullName));
}
IEnumerator LoadFile(string path)
{
WWW www = new WWW("file://" + path);
print("loading " + path);
AudioClip clip = www.GetAudioClip(false);
while (clip.loadState != AudioDataLoadState.Loaded)
yield return www;
print("done loading");
clip.name = Path.GetFileName(path);
print ("loaded:" + clip.name);
//clips.Add(clip);
}
I am stuck as how to proceed, the WWW seems to be used for during runtime, I only need it during Editor mode. Are the above functions able to run in editor mode?
Your answer
Follow this Question
Related Questions
Initialising List array for use in a custom Editor 1 Answer
(solved)Pasing WWW data post/get to load gameobjects? 4 Answers
How to fix unity editor UI, and what dose the icon in the bottom right mean? 2 Answers
GetPropertyHeight infinite recursion on drawer 1 Answer
Can I name a game object's components (in the editor)? 2 Answers