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 ...
随机推荐
- STM32F407第一步之点亮LED
STM32F407第一步之点亮LED. 要点亮LED,首先了解一下F4的GPIO模块.首先看一下STM32F4数据手册,GPIO模块的内部结构图 看上去有点复杂,不要怕,慢慢理解就可以了.对外引脚那里 ...
- SimpleThreadPool实践
前言 并发(Concurrency)一直谈论java绕不开的一个话题,从移动开发工程师到后端工程师,几乎所有的面试都要涉及到并发/多线程的一些问题.虽然多数时候我们使用线程池,都是已经实现好的框架—— ...
- javascrip小笔记
function getCookie(name) {//获取name为 var arr, reg = new RegExp("(^| )" + name + "=([^; ...
- Loadrunner---解决乱码问题
在使用Loadrunner录制和回放时有时候会因为乱码问题报错,且让我们很难定位出脚本问题所在.此事我们做一下分析loadrunner为什么会出现乱码这种情况呢? 1.乱码产生的原因 1)loadru ...
- 关于 C# 调用 JavaWebservice服务,版本不一致的问题
1. A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint. 问题原因: 客户端和服务端的SOAP协议版本不一 ...
- 艺术品照片融合到背景墙上效果及DEMO
演示地址: 功能:图片按照角度增加阴影,比较复杂的功能就是当墙面是不规则的时候,贴的艺术品必须按照墙面的角度进行变形处理.
- 【转】Java关键字final、static使用总结
转自:http://lavasoft.blog.51cto.com/62575/18771/ Java关键字final.static使用总结 一.final 根据程序上下文环境, ...
- matplotlib 显示中文 与 latex冲突
如果在使用中文之前包含了使用latex的语法: mpl.rcParams['text.usetex'] = True 将不能正确显示含有中文的图片. 附 显示中文的方法: from matplotli ...
- IP验证正则表达式
Regex r = new Regex(@"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$" ...
- Foundation ----->NSDictionary
/*_______________不可变字(NSDictionary)____________*/ //1.字典的创建 //值(value) NSArray *arr ...