mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-26 03:25:22 +00:00
f14d2a423f
* Super Retro VFX! * Updated Screen Jump default * also airboarder works now --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
28 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|
|
|