unity手动选择文件夹保存文件
来源:互联网 发布:卷积神经网络 算法 编辑:程序博客网 时间:2024/06/06 02:52
闲话不扯,直接开始正题:
1: 找到unity自带的 System.Windows.Forms.dll 文件,我的是在(C:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0\System.Windows.Forms.dll )
2:在项目中新建文件夹,名字叫 Plugins , 将 System.Windows.Forms.dll 添加进去。
3:设置unity :File - Build Settings... - Player Setting... - Other Settings - Api Compatibility Level 设置成 .NET 2.0
4:创建脚本 System_Windows_Froms.cs
using System;
using System.Collections;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using UnityEngine;
public class System_Windows_Froms : MonoBehaviour {
string CompentPath; //接受选择文件的路径
string UnityPath; //接受转成功后的路径 也就是Unity所需要的路径
//自定义文件保存文件夹;
public void SaveCutScreenPath()
{
FolderBrowserDialog fb = new FolderBrowserDialog(); //创建控件并实例化
fb.Description = "选择文件夹";
fb.RootFolder = Environment.SpecialFolder.MyComputer; //设置默认路径
fb.ShowNewFolderButton = false; //创建文件夹按钮关闭
//如果按下弹窗的OK按钮
if (fb.ShowDialog() == DialogResult.OK)
{
//接受路径
CompentPath= fb.SelectedPath;
}
//将路径中的 \ 替换成 / 由于unity路径的规范必须转
UnityPath= CompentPath.Replace(@"\", "/");
print(UnityPath);
//如果 \ 比较多的话
//if (UnityPath.IndexOf("/") > 2)
//{
//UnityPath = CompentPath+ "/";
//print("大于了");
//}
//else {
//print("小于了");
//}
}
}
- unity手动选择文件夹保存文件
- unity手动选择文件夹保存文件
- unity 打开文件夹并选择文件
- 选择文件对话框、保存文件对话框、选择文件夹对话框
- [Win32]打开文件/保存文件/选择文件夹对话框
- 选择保存文件夹
- 选择保存目录文件夹
- VB6.0 浏览文件夹对话框 选择文件保存路径
- C# 下载 解压 选择文件夹 保存文件 删除目录下文件及文件夹
- python qt(pyqt)的文件打开、文件保存、文件夹选择对话框
- C#选择文件、选择文件夹、打开文件夹
- swt 文件 文件夹 选择
- WinForm 文件/文件夹选择
- C#选择文件 文件夹
- c#保存文件时候的弹出选择要保存的文件夹带新建文件夹效果的类代码
- C#下载文件时候弹出选择文件夹保存目录的代码
- win10 uwp 保存用户选择文件夹
- 创建文件夹,并且保存文件
- python基础教程[2]:复制文件及文件夹
- 【Keil】warning: #550-D: variable "activeTaskID" was set but never used
- Hibernate源码解析
- html 使用js动态添加表格
- Docker run 命令
- unity手动选择文件夹保存文件
- Anonymous class puzzler习题
- SSH中Hibernate中报错No Hibernate Session bound to thread解决
- Java中数据类型及其之间的转换(转)
- 算法7 编码和解码TinyURL
- python 列表常用函数操作
- python学习笔记---对象赋值其实就是引用
- git的详细教程地址
- 新星Hcash超级现金矿池傻瓜版HSR挖矿指南-钱包流程,及1060 1070 1080 显卡速度对比