Guest User

PixelBoy

a guest
Dec 29th, 2015
2,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [ExecuteInEditMode]
  5. [AddComponentMenu("Image Effects/PixelBoy")]
  6. public class PixelBoy : MonoBehaviour
  7. {
  8.     public int w = 720;
  9.     int h;
  10.     protected void Start()
  11.     {
  12.         if (!SystemInfo.supportsImageEffects)
  13.         {
  14.             enabled = false;
  15.             return;
  16.         }
  17.     }
  18.     void Update() {
  19.  
  20.         float ratio = ((float)Camera.main.pixelHeight / (float)Camera.main.pixelWidth);
  21.         h = Mathf.RoundToInt(w * ratio);
  22.        
  23.     }
  24.     void OnRenderImage(RenderTexture source, RenderTexture destination)
  25.     {
  26.         source.filterMode = FilterMode.Point;
  27.         RenderTexture buffer = RenderTexture.GetTemporary(w, h, -1);
  28.         buffer.filterMode = FilterMode.Point;
  29.         Graphics.Blit(source, buffer);
  30.         Graphics.Blit(buffer, destination);
  31.         RenderTexture.ReleaseTemporary(buffer);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment