unity3D技术之WaitForEndOfFrame 等待帧结束.docxVIP

unity3D技术之WaitForEndOfFrame 等待帧结束.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
unity3D技术之WaitForEndOfFrame 等待帧结束

Inherits from YieldInstructionWaits until the end of the frame after all cameras and GUI is rendered, just before displaying the frame on screen.等待直到所有的摄像机和GUI被渲染完成后,在该帧显示在屏幕之前。You can use it to read the display into a texture, encode it as an image file (see Texture2D.ReadPixels and Texture2D.EncodeToPNG) and send it somewhere. 你可以使用它读取显示到纹理【狗刨学习网】,编码它为一个图片文件(参见Texture2D.ReadPixels和)并且发送到任意地方。C#JavaScriptusing UnityEngine;using System.Collections;public class example : MonoBehaviour {public IEnumerator Awake() {yield return new WaitForEndOfFrame();}}yield new WaitForEndOfFrame ();// Saves screenshot as PNG file.//保持屏幕为PNG文件import System.IO;// Take a shot immediately//立即截屏function Start() {UploadPNG();}function UploadPNG() {// We should only read the screen bufferafter rendering is complete//等待完成后读取屏幕缓存yield WaitForEndOfFrame();// Create a texture the size of the screen, RGB24 format//创建一个屏幕大小的图片,RGB24格式var width = Screen.width;var height = Screen.height;var tex = new Texture2D( width, height, TextureFormat.RGB24, false );// Read screen contents into the texture//到图片读取屏幕内容tex.ReadPixels( Rect(0, 0, width, height), 0, 0 );tex.Apply();// Encode texture into PNG//编码图片为PNG格式var bytes = tex.EncodeToPNG();Destroy( tex );// For testing purposes, also write to a file in the project folder//出于测试目的,也在工程文件夹保存一个文件// File.WriteAllBytes(Application.dataPath + /../SavedScreen.png, bytes);// Create a Web Form//创建一个Web表单var form = new WWWForm();form.AddField(frameCount, Time.frameCount.ToString());form.AddBinaryData(fileUpload,bytes);// Upload to a cgi script//上传到一个cgi脚本var w = WWW(http://localhost/cgi-bin/env.cgi?post, form);yield w;if (w.error != null)print(w.error);elseprint(Finished Uploading Screenshot);}// Shows alpha channel contents in the game view.// Requires Unity Pro as this script uses GL class.//在游戏视图中显示alpha通道的内容,需要Unity Pro专业版,这个脚本使用了GL类。private var mat : Material;// After the frame is completely rendered, well// draw a full screen quad that extracts the alpha channe

文档评论(0)

xcs88858 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档