此功能都在类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. html 学习资料列表

    HTML 教程 HTML 简介 html div 标签介绍 html span 标签介绍 html a 超链接标签 HTML Br换行标签介绍 HTML P段落标签介绍 HTML br与p标签区别 H ...

  2. 慕课网-Java入门第一季-6-10 练习题

    来源:http://www.imooc.com/ceping/1596 以下关于二维数组的定义和访问正确的是() A int[ ][ ] num = new int[ ][ ]; B int[ ][ ...

  3. 慕课网-Java入门第一季-6-7 使用 Arrays 类操作 Java 中的数组

    来源:http://www.imooc.com/code/1556 Arrays 类是 Java 中提供的一个工具类,在 java.util 包中.该类中包含了一些方法用来直接操作数组,比如可直接实现 ...

  4. IOS 在不打开电话服务的时候,可以响应服务器的推送消息,从而接收服务器的推送消息

    在做即时通讯(基于xmpp框架)的时候遇到这样一个问题,就是在真机测试的时候,你按Home键返回桌面,在你返回桌面的时候,这是你的程序的挂起状态的,在你挂起的时候, 相当于你的程序是死的,程序的所有进 ...

  5. android解析图片资源缩小放大问题

    今天突然发现,图片放在drawable 不同分辨率的目录下会有不同程度的放大或者缩小?这是为什么呢? 首先我们从decodeResource()方法入手 public static Bitmap de ...

  6. MongoDB(七)MongoDb数据结构

    首先,向数据库插入一条bjson数据 首先是定义文档,然后使用admin用户名密码登录,进入test数据库,向test数据库中插入此文档("表名称和表中的记录") 插入结果,查看m ...

  7. cursor 鼠标样式——属性

    取值: [ [<uri> ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-res ...

  8. JS 弹出层

    var name='提示';   //网页名称,可为空; var iWidth=550;      //弹出窗口的宽度; var iHeight=250;     //弹出窗口的高度; var iTo ...

  9. List集合的remove一个对象的方法

    import java.util.ArrayList;import java.util.List;class A{ public boolean equals(Object obj){ return ...

  10. ARCGIS进行地理配准并加载到谷歌地球中查看

    普通的地图图片如何能让其附有经纬度坐标和投影信息,如何能将普通的地图图片加载到诸如谷歌地球等相关的三维地球软件当中进行生产或学习使用呢,这就要用到gis当中常用的一种功能,叫做地理配准.地理配准并不复 ...