Skip to content

Instantly share code, notes, and snippets.

@sassembla
Created June 3, 2019 05:36
Show Gist options
  • Save sassembla/aa1f020dc1f093bc584128b375e5ce28 to your computer and use it in GitHub Desktop.
Save sassembla/aa1f020dc1f093bc584128b375e5ce28 to your computer and use it in GitHub Desktop.
[MenuItem("Window/TakeScreenshotWithCaptureScreenshotAsTexture")]
public static void Menu()
{
var tex = ScreenCapture.CaptureScreenshotAsTexture();
var jpgBytes = tex.EncodeToJPG(10);// 90KB
using (var sw = new StreamWriter("a.jpg"))
{
sw.BaseStream.Write(jpgBytes, 0, jpgBytes.Length);
}
}
@sassembla
Copy link
Author

Finally! you've got a perfect result! isn't it?

@torikizi
Copy link

torikizi commented Jun 4, 2019

take2
警告なし
2019.1.0f2 windows

caps

@sassembla
Copy link
Author

take2
警告なし
2019.1.0f2 windows

caps

Perfect! 素晴らしい。

@ishtaka
Copy link

ishtaka commented Jun 4, 2019

Mac 2018.2.2f1
エラー、警告なしでしたが

a
スクリーンショット 2019-06-04 23 51 56

@sassembla
Copy link
Author

conclusion:

Unity Editor 2019.1.0f2 windows can take valid screenshot on Editor without playing.

Unity Editor 2019.1.2f1 mac also can take valid screenshot onEditor with playing.

@sassembla
Copy link
Author

Mac 2018.2.2f1
エラー、警告なしでしたが

a
スクリーンショット 2019-06-04 23 51 56

Thank you!

@sassembla
Copy link
Author

sassembla commented Jun 25, 2019

limited: free aspect mode required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment