admin 管理员组文章数量: 1184232
之前项目中需要用到截图功能,经过查找找到3种方式,这里做一个记录。
Application.CaptureScreenshot
Application
类下的
CaptureScreenshot
方法,截取的是某一帧时整个游戏的画面,或者说是全屏截图吧。
以下是两个重载的函数。其中
filename
参数为截图后保存下来的文件名;
superSize
参数为增加分辨率的因数:
//// 摘要:// Captures a screenshot at path filename as a PNG file.//// 参数:// filename:// Pathname to save the screenshot file to.//// superSize:// Factor by which to increase resolution.[Obsolete("Application.CaptureScreenshot is obsolete. Use ScreenCapture.CaptureScreenshot instead (UnityUpgradable) -> [UnityEngine] UnityEngine.ScreenCapture.CaptureScreenshot(*)",true)]publicstaticvoidCaptureScreenshot(string filename);//// 摘要:// Captures a screenshot at path filename as a PNG file.//// 参数:// filename:// Pathname to save the screenshot file to.//// superSize:// Factor by which to increase resolution.[Obsolete("Application.CaptureScreenshot is obsolete. Use ScreenCapture.CaptureScreenshot instead (UnityUpgradable) -> [UnityEngine] UnityEngine.ScreenCapture.CaptureScreenshot(*)",true)]publicstaticvoidCaptureScreenshot(string filename,int superSize);
通过上面的代码也可以看出,在新版的Unity中该函数被废弃了。新的系统函数类是
ScreenCapture
。
ScreenCapture
以下为系统类
ScreenCapture
:
//// 摘要:// Functionality to take Screenshots.[NativeHeader("Modules/ScreenCapture/Public/CaptureScreenshot.h")]publicstaticclassScreenCapture{
publicstaticvoidCaptureScreenshot(string filename);//// 摘要:// Captures a screenshot at path filename as a PNG file.//// 参数:// filename:// Pathname to save the screenshot file to.//// superSize:// Factor by which to increase resolution.//// stereoCaptureMode:// Specifies the eye texture to capture when stereo rendering is enabled.publicstaticvoidCaptureScreenshot(string filename,int superSize);publicstaticvoidCaptureScreenshot(string filename,StereoScreenCaptureMode stereoCaptureMode);publicstaticTexture2DCaptureScreenshotAsTexture版权声明:本文标题:Unity中的截图方法(包括全屏截图、区域截图、Camera截图和摄像头截图)_unity 截图 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1774349196a3570711.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论