Skip to content

Instantly share code, notes, and snippets.

@Demkeys
Last active August 5, 2018 23:59
Show Gist options
  • Save Demkeys/bef8516ea7b15282fda706bd462672e2 to your computer and use it in GitHub Desktop.
Save Demkeys/bef8516ea7b15282fda706bd462672e2 to your computer and use it in GitHub Desktop.
Simple example showing how to use the Screencapture class.
/// <summary>
/// Attach this script to any gameobject in the scene, enter Play Mode, then hit Space on your keyboard to capture a screenshot.
/// Exit Play Mode, refresh the Project panel, and the scenecap image should be in the Assets folder.
/// </summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScreencapScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Space))
{
ScreenCapture.CaptureScreenshot(Application.dataPath + "/screencap.png");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment