unity 实现另一个unity软件的安装工具(2)——选在安装 unity打开资源管理器对话框


#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乱报。!!

你可能感兴趣的:(Unity)