Files
JJBB/Assets/Project/Script/Player/Controller/CameraLowRes.cs
2024-08-23 15:49:34 +08:00

38 lines
821 B
C#

using UnityEngine;
[RequireComponent(typeof(Camera))]
public class CameraLowRes : MonoBehaviour
{
private Camera _camera;
private RenderTexture _temp;
private void Awake()
{
_camera = GetComponent<Camera>();
}
private void OnPreRender()
{
_camera.targetTexture = _temp;
}
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
_camera.targetTexture = null;
Graphics.Blit(src, null as RenderTexture);
}
private void OnEnable()
{
if (_temp == null)
_temp = RenderTexture.GetTemporary(Screen.width / 2, Screen.height / 2);
}
private void OnDisable()
{
if (_temp != null)
{
RenderTexture.ReleaseTemporary(_temp);
_temp = null;
}
}
}