Unity snippet for supersizing in-engine screenshots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Take up to 10 screenshots per session, then start overwriting | |
private IEnumerator Capture(string path=null, string filename=null) { | |
Log.Debug(string.Format("ScreenCapture.Capture(path: {0}, filename: {1}) Settings.DataPath={0}", path, filename, Settings.DataPath)); | |
screenShotCount += 1; | |
if (screenShotCount > 10) { | |
screenShotCount = 1; | |
} | |
if (filename == null) { | |
filename = string.Format("Screenshot{0}.png", screenShotCount.ToString()); | |
} | |
if ((Application.platform != RuntimePlatform.IPhonePlayer) && (Application.platform != RuntimePlatform.Android)) { | |
// iOS and Android already include persistentDataPath in CaptureScreenshot | |
if (path == null) { | |
filename = System.IO.Path.Combine(Settings.DataPath, filename); | |
} | |
else { | |
filename = System.IO.Path.Combine(path, filename); | |
} | |
} | |
// @1x | |
Log.Debug(string.Format("ScreenCapture.Screenshot() @1x filename={0}", filename)); | |
yield return new WaitForEndOfFrame(); | |
int superSize = 0; | |
#if JAMMER_SCREENCAPTURE_SUPERSIZE_2X | |
superSize = 2; | |
#elif JAMMER_SCREENCAPTURE_SUPERSIZE_4X | |
superSize = 4; | |
#elif JAMMER_SCREENCAPTURE_SUPERSIZE_8X | |
superSize = 8; | |
#endif | |
// | |
// NOTE: May need to disable anti-aliasing in quality settings if you get a black screen | |
// | |
Application.CaptureScreenshot(filename, superSize: superSize); | |
Events.Raise(new PlaySFXCommandEvent() { Handled=false, SFX=SFX.Click }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment