3DSelfie  Hansjoerg Hofer (1026632), Sebastian Metzler (0927550)
Render2Texture.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 
9 public class Render2Texture : MonoBehaviour {
10 
11  public Texture2D textOut;
12  RenderTexture rt;
13  private bool once;
14 
20  void OnEnable () {
21  rt = GetComponent<Camera>().targetTexture as RenderTexture;
22  textOut = new Texture2D (rt.width, rt.height);
23  GetComponent<Camera> ().enabled = true;
24  GetComponent<Camera>().Render();
25  }
26 
32  void OnPostRender () {
33  textOut.ReadPixels (new Rect (0, 0, rt.width, rt.height), 0, 0);
34  textOut.Apply();
35  enabled = false;
36  GetComponent<Camera> ().enabled = false;
37  }
38 }
Render2Texture Script.
Texture2D textOut