WaitForEndOfFrame
2017-08-08 18:54
375 查看
using System.IO; using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { // Take a shot immediately IEnumerator Start() { UploadPNG(); } IEnumerator UploadPNG() { // We should only read the screen buffer after rendering is complete yield return new WaitForEndOfFrame(); // Create a texture the size of the screen, RGB24 format int width = Screen.width; int height = Screen.height; Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false); // Read screen contents into the texture tex.ReadPixels(new Rect(0, 0, width, height), 0, 0); tex.Apply(); // Encode texture into PNG byte[] 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 WWWForm form = new WWWForm(); form.AddField("frameCount", Time.frameCount.ToString()); form.AddBinaryData("fileUpload", bytes); // Upload to a cgi script WWW w = new WWW("http://localhost/cgi-bin/env.cgi?post", form); yield return w; if (w.error != null) print(w.error); else print("Finished Uploading Screenshot"); } }
相关文章推荐
- unity3D技术之WaitForEndOfFrame 等待帧结束
- Unity3D 中 脚本(MonoBehaviour) 生命周期WaitForEndOfFrame需要注意的地方
- 关于” fatal error C1010: unexpected end of file while looking forprecompiled header directive”问题
- Testing for end of input[转]
- 【转载】fatal error C1010: unexpected end of file while looking for precompiled header directive
- 论文阅读:End-to-End Learning of Deformable Mixture of Parts and Deep Convolutional Neural Networks for H
- 如何解决unexpected end of file while looking for precompiled header directive的问题
- C语言常见问题:unexpected end of file while looking for precompiled header directive
- scripts for query proportion of the on-idle wait time is taken up by these wait classes
- SurfaceFlinger/gralloc Out of Memory error when allocating buffer memory for use with virtual frame
- 读《The End of an Architectural Era (It’s Time for a Complete Rewrite)》
- VC++6.0 unexpected end of file while looking for precompiled header directive
- fatal error C1010: unexpected end of file while looking for precompiled header directive该如何解决
- End-to-end learning of action detection from frame glimpses in videos 阅读笔记
- 编译错误 fatal error C1010: unexpected end of file while looking for precompiled header directive
- 解决错误 fatal error C1010: unexpected end of file while looking for precompiled head
- End-to-End Training of Hybrid CNN-CRF Models for Stereo
- fatal error C1010: unexpected end of file while looking for precompiled head
- 如何解决unexpected end of file while looking for precompiled header directive的问题
- fatal error C1010: unexpected end of file while looking for precompiled header directive 错误解决办法