Advertisement
WaterChicken

FakeRenderTexture

Jul 11th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class FakeRenderTexture : MonoBehaviour {
  5.     public Texture2D texture;
  6.     public float updateFrequency = .5f;
  7.     private float lastUpdate = 0f;
  8.     private Rect sourceRect;
  9.  
  10.     void Start() {
  11.         sourceRect = new Rect (0, 0, texture.width, texture.height);
  12.         camera.pixelRect = sourceRect;
  13.     }
  14.  
  15.     void OnPostRender() {
  16.         if (Time.time > lastUpdate + updateFrequency) {
  17.             lastUpdate = Time.time;
  18.             texture.ReadPixels (sourceRect, 0, 0);
  19.             texture.Apply ();
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement