Advertisement
dnnkeeper

Unity Screenshotter

Feb 22nd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Screenshotter : MonoBehaviour {
  5.  
  6.     [Header("Ctrl+")]
  7.     public KeyCode ScreenshotButton;
  8.  
  9.     [Range(0,10)]
  10.     public int SuperScreenMultiplier;
  11.  
  12.     [Header("read only")]
  13.     public Vector2 screenshotResolution;
  14.  
  15.     void Awake(){
  16.         if (ScreenshotButton == null)
  17.             ScreenshotButton = KeyCode.Space;
  18.     }
  19.  
  20.     // Update is called once per frame
  21.     void Update () {
  22.         screenshotResolution = new Vector2( Camera.main.pixelRect.width * SuperScreenMultiplier, Camera.main.pixelRect.height * SuperScreenMultiplier);
  23.         if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(ScreenshotButton) )
  24.         {
  25.             System.DateTime time = System.DateTime.Now;
  26.             string path = Application.productName +"_"+time.Minute+"_"+time.Second+".png";
  27.             Debug.Log ("Screenshot captured! " + path);
  28.             Application.CaptureScreenshot (path, SuperScreenMultiplier);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement