HeavenStudioPlus/Assets/Shaders/OilPainting/BuiltInSampleScripts/BackgroundManager.cs
wookywok 92962fef26
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

28 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BackgroundManager : MonoBehaviour
{
public ScreenCaptureManager screenCaptureManager;
public ImageEffectController imageEffectController;
public RawImage backgroundImage;
public void CaptureAndSetBackground()
{
Texture2D capturedScreen = screenCaptureManager.CaptureScreen();
RenderTexture rt = RenderTexture.GetTemporary(capturedScreen.width,
capturedScreen.height);
Graphics.Blit(capturedScreen, rt, imageEffectController.effectMaterial);
Texture2D processedTexture = new Texture2D(capturedScreen.width,
capturedScreen.height, TextureFormat.RGB24, false);
RenderTexture.active = rt;
processedTexture.ReadPixels(new Rect(0, 0, capturedScreen.width,
capturedScreen.height), 0, 0);
processedTexture.Apply();
RenderTexture.active = null;
backgroundImage.texture = processedTexture;
RenderTexture.ReleaseTemporary(rt);
}
}