Hey, I have a UI Dropdown and in the Start() I am loading a list of audio files that have the .aiff extension. When the player selects an item from the dropdown I am trying to replace an Audio Clip but the path seems to be incorrect?
I am creating a Dictionary and using the Name of the file at the path as the KEY and then saving the path as the value. When the user pulls down the dropdown and selects the item I am using the KEY to get the path to the file but the Audio Clip is still null. I am sure I am screwing up the path some how but when I print the path it seems valid
I am working off of a thumb drive called NO NAME at the moment while out of the office.
void Start () {
clipLengthText.text = audioClip.length.ToString();
nameField.text = audioClip.name;
DirectoryInfo levelDirectoryPath = new DirectoryInfo(Application.dataPath);
fileInfo = levelDirectoryPath.GetFiles("*.*", SearchOption.AllDirectories);
dropNamesList = new List<string>();
for (int i = 0; i < fileInfo.Length; i++)
{
if (fileInfo[i].Name.EndsWith(".aiff"))
{
dropNamesList.Add(fileInfo[i].Name);
print("Info: " + fileInfo[i].Name);
print(fileInfo[i]);
pathDict.Add(fileInfo[i].Name, fileInfo[i].ToString());
//print("fn: " + pathDict[fileInfo[i].FullName]);
}
}
listDropDown.ClearOptions();
listDropDown.AddOptions(dropNamesList);
}
public void DropdownValueChanged(Dropdown change)
{
audioSource.Stop();
print(dropNamesList[change.value]);
nameField.text = dropNamesList[change.value];
AudioClip clip = Resources.Load(pathDict[dropNamesList[change.value]]) as AudioClip;
print((clip != null)? "The Clip is valid " : "No Clip");
audioSource.clip = clip;
audioSource.Play();
}