Unity使用Windows弹窗保存图片
此功能都在类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弹窗保存图片的更多相关文章
- Unity调用Windows弹框、提示框(确认与否,中文)
Unity调用Windows弹提示框 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...
- 【使用Unity开发Windows Phone上的2D游戏】(1)千里之行始于足下
写在前面的 其实这个名字起得不太欠当,Unity本身是很强大的工具,可以部署到很多个平台,而不仅仅是可以开发Windows Phone上的游戏. 只不过本人是Windows Phone 应用开发出身, ...
- 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 ...
- (译)【Unity教程】使用Unity开发Windows Phone上的横版跑酷游戏
译者注: 目前移动设备的跨平台游戏开发引擎基本都是采用Cocos2d-x或者Unity.一般而言2d用cocos2d-x 3d用unity,但是对于Windows Phone开发者, cocos2d- ...
- unity 打包 windows 运行 紫色 粉红色
unity下建立了个小demo,在editer里面运行正常.如下 但是一旦打包发布到android或者windows下就出现了类似这种情况 这种一般是由于材质贴图的缺失,一般来说选定的默认贴图的话会打 ...
- Unity调用Windows对话框保存时另存为弹框
Unity开发VR之Vuforia 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...
- 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 ...
- 【使用Unity开发Windows Phone上的2D游戏】(2)初识工具
下载工具 我们需要下载两个工具:Unity 和 2D Toolkit Unity 在我写这篇文章的时候,最新的Unity版本是4.2.1, 下载地址 Unity公司的开发效率实在是很高,我一个多月前开 ...
- Unity发布Windows程序遇到的问题
Unity版本:5.6.2 因为程序中使用了Networking模块,所以在打包发布的时候需要登录Unity的账号,并做设置. 错误信息如下: 解决办法如下: 先登录Unity账号,并在Service ...
随机推荐
- web页面设计基本原则
1.对齐. 不对齐看起来糟糕极了.简直一片混乱,会给人一种很不专业的印象.对齐让页面更漂亮一些,更重要的是便于更好的传达信息. 2.去掉糟糕的边框.边框会产生一种分离感. 3.亲密性. 元素相互靠近看 ...
- 【转】Hibernate级联注解CascadeType参数详解
cascade(级联) 级联在编写触发器时经常用到,触发器的作用是当 主控表信息改变时,用来保证其关联表中数据同步更新.若对触发器来修改或删除关联表相记录,必须要删除对应的关联表信息,否则,会存有脏数 ...
- flex acionscript png图片去除多余空白,生成合适大小图片
//最小矩形(非透明最小区域) public static function getMinRect(target:BitmapData):Rectangle{ return target.getC ...
- zz Must read
http://www.opengpu.org/forum.php?mod=viewthread&tid=965&extra=page%3D1 游戏引擎剖析(Game Engine An ...
- 关于oracle中创建新表时将我们要用的表的结构和数据都复制过去
今天在oracle中遇到了一个问题,就是给我查询出来了一张表的数据,只有部分的字段,让我将这张表的结构和数据放到新的临时表中,并进行数据的查询. 我是这样做的: 如:create table tabl ...
- [转]DevExpress.XtraGrid.GridControl gridView自动列宽代码
gridView1.OptionsView.ColumnAutoWidth = false; for (int I = 0; I < gridView1.Columns.Count; I++ ...
- webstorm编辑RN代码提示功能
需要下载一个文件. 1. 进入你想存储这个文件的目录,按住shift+鼠标右键,选择“在此处打开命令窗口” 2. 在命令窗口中输入 git clone https://github.com/virt ...
- Linux SAMBA Practical
Samba配置 on Ap1-10.*.16.81首先,判斷samba服務是否安裝?[root@ap01 ~]# rpm -qa|grep sambasamba-client-3.5.10-125.e ...
- According to TLD or attribute directive in tag file, attribute test does not accept any expressions
HTTP Status 500 - /WEB-INF/views/emp/list.jsp (line: 30, column: 4) According to TLD or attribute di ...
- docker help
localhost == 127.0.0.1 == 本机ip ifconfig 或者 ip addr 查看本地宿主机的ip地址 $ docker help Usage: docker [OPTIONS ...