Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Screenshot : MonoBehaviour {
- public string prefname="LastScreenshotNumber";
- public string screenshotprefix;
- public string screenshotsuffix;
- public int startAtShot=100;
- public float ssDelay=1f;
- public KeyCode ssKey=KeyCode.F2;
- float nextSSAt;
- // Use this for initialization
- void Start () {
- if (!PlayerPrefs.HasKey(prefname)){
- PlayerPrefs.SetInt(prefname,startAtShot);
- }
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKey(ssKey)&&Time.timeSinceLevelLoad>=nextSSAt){
- int cshotn=PlayerPrefs.GetInt(prefname);
- cshotn++;
- string ssname=Application.dataPath+"/"+screenshotprefix+cshotn.ToString()+screenshotsuffix+".png";
- Debug.Log ("Taking screenshot "+ssname);
- Application.CaptureScreenshot( ssname);
- PlayerPrefs.SetInt(prefname,cshotn);
- nextSSAt=Time.timeSinceLevelLoad+ssDelay;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement