Capturing the Screen
Screen capture will capture the final rendering to screen, including all UI elements (even IMGUI) and post-processes effects.
Note
Currently capture is only possible from one of the displays. When using multiple displays the last one will be captured.
The final screen output can be captured in-editor using the Movie Capture editor window.
The CaptureFromScreen
component can be used for generate capture as part of your application. Simple add this component to a GameObject
and set the capture settings needed in the Inspector Window, or via Scripting.
Here is an example of capturing the screen via scripting:
using UnityEngine;
using RenderHeads.Media.AVProMovieCapture;
public class ScreenCaptureExample : MonoBehaviour
{
void Start()
{
GameObject go = new GameObject();
CaptureFromScreen capture = go.AddComponent<CaptureFromScreen>();
capture.IsRealTime = false;
capture.FrameRate = 60f;
capture.StopMode = StopMode.FramesEncoded;
capture.StopAfterFramesElapsed = capture.FrameRate * 10f;
capture.StartCapture();
}
void Update()
{
if (KeyCode.GetKeyDown(KeyCode.S))
{
_capture.StartCapture();
}
if (KeyCode.GetKeyDown(KeyCode.S))
{
_capture.StopCapture();
}
}
}