38 lines
821 B
C#
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;
|
|
}
|
|
}
|
|
} |