HeavenStudioPlus/Assets/Shaders/OilPainting/BuiltInSampleScripts/ScreenCaptureManager.cs
wookywok f14d2a423f Retro VFX! (also airboarder works now) (#780)
* Super Retro VFX!

* Updated Screen Jump default

* also airboarder works now

---------

Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-03-11 21:21:51 +00:00

23 lines
720 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScreenCaptureManager : MonoBehaviour
{
public Texture2D CaptureScreen()
{
RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 24);
Camera.main.targetTexture = rt;
Camera.main.Render();
Camera.main.targetTexture = null;
Texture2D screenShot = new Texture2D(Screen.width, Screen.height,
TextureFormat.RGB24, false);
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
screenShot.Apply();
RenderTexture.active = null;
Destroy(rt);
return screenShot;
}
}