0
我有一个下拉列表,我想读取某个文件夹中的所有文件,然后将它们作为下拉选项。 Unity UI下拉选项从文件夹
if (obj.name.Contains("AudioSphere"))
{
// Finding the dropdown menu with tag "audioDropdown"
Dropdown dropdown = GameObject.FindGameObjectWithTag("audioDropdown");
// Finding all the music files
FileInfo[] options = getAudioFiles();
// add Options to the dropdown from list
for (FileInfo data : options) {
dropdown.AddOptions(new Dropdown.OptionData(data.Name));
}
}
我遇到了很多的错误,我需要一些帮助他们。我是Unity中所有这些UI的新手。
private FileInfo[] getAudioFiles()
{
String path = Application.dataPath + "/Resources/Audiofiles";
// How to check if exists?
DirectoryInfo audioFolder = new DirectoryInfo(@path);
FileInfo[] audioFiles = audioFolder.GetFiles();
throw new NotImplementedException();
}