void Update() { if (cam == null) { cam = GetComponent <Camera>(); } if (mainCam == null) { mainCam = GetComponentInParent <Camera>(); } if (compositor == null) { compositor = GetComponentInParent <RenderTextureCompositor>(); } if (cam == null || mainCam == null || compositor == null) { return; } CalculateTargetWidth(); if (rt == null || rt.width != targetWidth) { rt = new RenderTexture(targetWidth, targetWidth, 1, RenderTextureFormat.ARGB32); rt.filterMode = FilterMode.Point; rt.useMipMap = false; rt.wrapMode = TextureWrapMode.Clamp; } cam.targetTexture = rt; cam.orthographicSize = (targetWidth / 48f); compositor.SetRenderTexture(rt); currentTargetWidth = targetWidth; Shader.SetGlobalInt("_UnevenResolution", Application.isPlaying ? (targetWidth % 2) : 0); }
public void UpdateCamera() { if (cam == null) { cam = GetComponent <Camera>(); } if (mainCam == null) { mainCam = GetComponentInParent <Camera>(); } if (compositor == null) { compositor = FindObjectOfType <RenderTextureCompositor>(); } if (renderTextureCamera == null) { renderTextureCamera = FindObjectOfType <RenderTextureCamera>(); } if (cam == null || mainCam == null || compositor == null || renderTextureCamera == null) { return; } targetWidth = renderTextureCamera.GetCurrentTargetWidth(); if (targetWidth == 0) { targetWidth = 411; } if (rt == null || rt.width != targetWidth) { rt = new RenderTexture(targetWidth, targetWidth, 1, RenderTextureFormat.ARGB32); rt.filterMode = FilterMode.Point; rt.useMipMap = false; rt.wrapMode = TextureWrapMode.Clamp; } cam.targetTexture = rt; cam.orthographicSize = (targetWidth / 48f); compositor.SetUIRenderTexture(rt); }