- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
- public void Start () {
- StartCoroutine(CaptureScreen());
- }
- IEnumerator CaptureScreen () {
-
- yield return new WaitForEndOfFrame();
- float width = Screen.width;
- float height = Screen.height;
- Texture2D 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
- Byte[] bytes = tex.EncodeToPNG();
- Destroy (tex);
- File.WriteAllBytes(Application.dataPath + "/../SavedScreen.png", bytes);
- }
复制代码 |
|