Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- //Modified version of http://wiki.unity3d.com/index.php?title=ScreenShotMovie
- //Added toggle
- //Fixed issue with screenshot output path
- public class ScreenshotMovie : MonoBehaviour
- {
- // The folder we place all screenshots inside.
- // If the folder exists we will append numbers to create an empty folder.
- public string folder = "ScreenshotMovieOutput";
- public int frameRate = 25;
- public int sizeMultiplier = 1;
- private string realFolder = "";
- private bool toggled = false;
- void Start()
- {
- // Set the playback framerate!
- // (real time doesn't influence time anymore)
- Time.captureFramerate = frameRate;
- // Find a folder that doesn't exist yet by appending numbers!
- realFolder = folder;
- int count = 1;
- while ( System.IO.Directory.Exists( realFolder ) ) {
- realFolder = folder + count;
- count++;
- }
- // Create the folder
- System.IO.Directory.CreateDirectory( realFolder );
- }
- void Update()
- {
- if ( Input.GetKeyDown( "f9" ) ) {
- toggled = !toggled;
- }
- if ( !toggled ) {
- return;
- }
- // name is "realFolder/shot 0005.png"
- var name = string.Format( "{0}/shot {1:D04}.png", Application.dataPath + "/../" + realFolder, Time.frameCount );
- // Capture the screenshot
- Application.CaptureScreenshot(name, sizeMultiplier);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement