You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/StompyRobot/SRDebugger/Scripts/Internal/BugReportScreenshotUtil.cs

30 lines
764 B
C#

1 month ago
namespace SRDebugger.Internal
{
using System.Collections;
using UnityEngine;
public class BugReportScreenshotUtil
{
public static byte[] ScreenshotData;
public static IEnumerator ScreenshotCaptureCo()
{
if (ScreenshotData != null)
{
Debug.LogWarning("[SRDebugger] Warning, overriding existing screenshot data.");
}
yield return new WaitForEndOfFrame();
var tex = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
tex.Apply();
ScreenshotData = tex.EncodeToPNG();
Object.Destroy(tex);
}
}
}