#if UNITY_EDITOR
path = EditorUtility.OpenFolderPanel("选择开文件夹", defaultPath, name);
#elif UNITY_STANDALONE_WIN
FolderBrowserDialog dialog = new FolderBrowserDialog
{
ShowNewFolderButton = true,
//RootFolder = Environment.SpecialFolder.MyDocuments,
SelectedPath = "C:",
Description = "请选择保存目录"
};
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK || result == DialogResult.Yes)
{
path = dialog.SelectedPath;
}
dialog.Dispose();
#endif
if (string.IsNullOrEmpty(path))
{
path = folderPath;
}
if (!string.IsNullOrEmpty(name))
if (!Path.GetFileName(path).Equals(name))
{
Directory.Delete(folderPath);
}
return path;
注意:在运行时需要引入System.Windows.Forms.dll,需要找到合适的版本。当时弄了好久,才终于明白unity发布的mono库才是能用的,其他的各种bug乱报。!!