此功能都在类EditorUtility中(using UnityEditor;)

包括

OpenFilePanel
打开文件窗口
Displays the "open file" dialog and returns the selected path name.
展示“打开文件”对话框并返回所选择的路径名称

OpenFilePanelWithFilters
打开文件窗口(带过滤类型)
Displays the "open file" dialog and returns the selected path name.
展示“打开文件”对话框并返回所选择的路径名称

OpenFolderPanel
打开文件夹窗口
Displays the "open folder" dialog and returns the selected path name.
展示“打开文件夹”对话框并返回所选择的路径名称

SaveFilePanel
保存文件窗口
Displays the "save file" dialog and returns the selected path name.
展示“保存文件”对话框并返回所选择的路径名称

SaveFilePanelInProject
保存文件窗口(项目中文件)
Displays the "save file" dialog in the Assets folder of the project and returns the selected path name.
展示项目的Assets文件夹中的“保存文件”对话框并返回所选择的路径名称

SaveFolderPanel
保存文件夹窗口
Displays the "save folder" dialog and returns the selected path name.
展示“保存文件夹”对话框并返回所选择的路径名称

下面的代码,将屏幕截图并保存到本地

using System.Collections;
using System.IO;
using UnityEditor;
using UnityEngine; public class SaveScreen : MonoBehaviour
{
private string time; // Use this for initialization
private void Start()
{
StartCoroutine(Save());
} // Update is called once per frame
private void Update()
{
} private IEnumerator Save()
{
yield return new WaitForEndOfFrame(); int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D(width, height, TextureFormat.ARGB32, false); tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply(); byte[] bytes = tex.EncodeToPNG();
Destroy(tex); var path = EditorUtility.SaveFolderPanel("请选择本地文件夹保存", "", ""); if (path.Length != 0)
{
if (bytes != null)
{
File.WriteAllBytes(path + "/" + time + ".png", bytes);
}
}
}
}

最后,附上效果图

关于Unity进行更多的windows交互,请参阅官方网站

https://docs.unity3d.com/ScriptReference/EditorUtility.html

声明:此博客为个人学习之用,如与其他作品雷同,纯属巧合,并请明示指出

Unity使用Windows弹窗保存图片的更多相关文章

  1. Unity调用Windows弹框、提示框(确认与否,中文)

    Unity调用Windows弹提示框 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...

  2. 【使用Unity开发Windows Phone上的2D游戏】(1)千里之行始于足下

    写在前面的 其实这个名字起得不太欠当,Unity本身是很强大的工具,可以部署到很多个平台,而不仅仅是可以开发Windows Phone上的游戏. 只不过本人是Windows Phone 应用开发出身, ...

  3. Unity for Windows: III–Publishing your unity game to Windows Phone Store

    原地址:http://digitalerr0r.wordpress.com/2013/08/27/unity-for-windows-iiipublishing-to-windows-phone-st ...

  4. (译)【Unity教程】使用Unity开发Windows Phone上的横版跑酷游戏

    译者注: 目前移动设备的跨平台游戏开发引擎基本都是采用Cocos2d-x或者Unity.一般而言2d用cocos2d-x 3d用unity,但是对于Windows Phone开发者, cocos2d- ...

  5. unity 打包 windows 运行 紫色 粉红色

    unity下建立了个小demo,在editer里面运行正常.如下 但是一旦打包发布到android或者windows下就出现了类似这种情况 这种一般是由于材质贴图的缺失,一般来说选定的默认贴图的话会打 ...

  6. Unity调用Windows对话框保存时另存为弹框

    Unity开发VR之Vuforia 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...

  7. Unity for Windows: II – Publishing Unity games to Windows Store

    原地址:http://digitalerr0r.wordpress.com/2013/08/27/unity-for-windows-ii-publishing-to-windows-8/ Windo ...

  8. 【使用Unity开发Windows Phone上的2D游戏】(2)初识工具

    下载工具 我们需要下载两个工具:Unity 和 2D Toolkit Unity 在我写这篇文章的时候,最新的Unity版本是4.2.1, 下载地址 Unity公司的开发效率实在是很高,我一个多月前开 ...

  9. Unity发布Windows程序遇到的问题

    Unity版本:5.6.2 因为程序中使用了Networking模块,所以在打包发布的时候需要登录Unity的账号,并做设置. 错误信息如下: 解决办法如下: 先登录Unity账号,并在Service ...

随机推荐

  1. 【原】redis插件安装

    wget -c https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz -O phpredis-2.2.4.tar.gz tar xzf ...

  2. Python Quick list dir

    昨天 Python释放了 3.5 ,添加了 os.scandir 根据文档该API比os.listdir快Docs which speeds it up by 3-5 times on POSIX s ...

  3. Java Docs

    1 Java Docs on Oracle:   1.1 Online(EN): JavaSE6  http://docs.oracle.com/javase/6/docs/api/index.htm ...

  4. Nginx 502错误触发条件与解决办法汇总(转载)

    一些运行在Nginx上的网站有时候会出现“502 Bad Gateway”错误,有些时候甚至频繁的出现.有些站长是在刚刚转移到Nginx之后就出现了这个问题,所以经常会怀疑这是不是Nginx的问题,但 ...

  5. 修改BIND9实现TCP DNS

    近日适逢某平方节日,Google国外网站陆续出现被墙的状况,想必大家都是知道的. 其实本人一直在使用SSH的Socket代理功能爬梯子,效果还是不错的,加上学校有原生IPv6支持,就算不走代理一般也能 ...

  6. iPad 控件UIPopoverController使用

    UIPopoverController 是iPad特有控件,(iOS7-9),在iOS9之后别废弃 使用步骤 设置内容控制器 UIPopoverController直接继承NSObject,不具备可视 ...

  7. Use Spring transaction to simplify Hibernate session management

    Spring对Hibernate有很好的支持    DataSource ->SessionFactory-> HibernateTranscationManagerHibernate中通 ...

  8. JAVA Socket 编程学习笔记(二)

    在上一篇中,使用了 java Socket+Tcp/IP  协议来实现应用程序或客户端--服务器间的实时双向通信,本篇中,将使用 UDP 协议来实现 Socket 的通信. 1. 关于UDP UDP协 ...

  9. gulp使用笔记

    gulp简介 gulp 是基于 Nodejs 的自动任务运行器,能自动化地完成javascript/coffee/sass/less/html/image/css等文件的的测试.检查.合并.压缩.格式 ...

  10. mvc4 分离Controller 出现 未找到路径“/”的控制器或该控制器未实现 IController

    一般MVC项目都会把Controller 分离出来独立类库,以前用mvc3一直这样做,测试发布都能够正常运行,这次用了mvc4,发现会报错:HTTP 404.您正在查找的资源(或者它的一个依赖项)可能 ...