LD48 jamming: auto-screenshot taker

// script name: ScreenshotHandler.cs
// how to use: make a gameobject and attach this script into it
// now every time you launch your game, it takes 
// one screenshot after 5 secs have passed

using UnityEngine;
using System.Collections;

public class ScreenshotHandler : MonoBehaviour {

	private void capture() {
		Application.CaptureScreenshot("screenshots/screenshot_"+System.DateTime.Now.ToString("yyyy_MM_dd-hh_mm_ss") +".png");
	}

	private bool _takeStartScreenshot;

	// Use this for initialization
	void Start () {
		_takeStartScreenshot = true;
	
	}
	
	// Update is called once per frame
	void Update () {
		if (this._takeStartScreenshot == true && Time.time > 5.0F) {
			// take a screenshot after 5 secs have passed
			this.capture();
			_takeStartScreenshot = false;
		}
		if (Input.GetKeyDown(KeyCode.F12)) {
			this.capture();
		}
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Pro-Human Quiz: