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));
}
}
私はエラーをたくさん会って、私は彼らといくつかの助けを必要としています。私はユニティのこれらの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();
}