-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
MediaCapture.cs
34 lines (29 loc) 路 1.02 KB
/
MediaCapture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections;
using UnityEngine;
namespace AdrianMiasik.Components.Specific.Automation
{
/// <summary>
/// A MonoBehaviour script that gets created by our <see cref="MediaCreator"/> that allows us to use coroutines
/// from a static context, specifically used for taking screenshots at the end of our frame.
/// </summary>
public class MediaCapture : MonoBehaviour
{
private static MediaCapture _instance;
private void Awake()
{
_instance = this;
}
IEnumerator TakeScreenshot(string filename, Action nextAction = null)
{
yield return new WaitForEndOfFrame();
ScreenCapture.CaptureScreenshot(filename);
Debug.Log("Screenshot '" + filename + "' Taken!");
nextAction?.Invoke();
}
public void CaptureScreenshot(string filename, Action nextAction)
{
_instance.StartCoroutine(TakeScreenshot(filename, nextAction));
}
}
}