- Home /
How to "print" what a camera is viewing in a plane?
Hello
I was wondering how you can "print" (I don't know what other word to use) what a camera is viewing to a 3d object.
Lets say that I have a hall that contains a security camera. I want to have what that camera is viewing in a plane.
Note that I have a main camera (The one with the character). So it will be like if you stand in front of a tv to see it.
Thanks.
Answer by robertbu · Jan 15, 2014 at 02:32 PM
RenderTextures will do this, but they are a Pro-only feature:
http://docs.unity3d.com/Documentation/Components/class-RenderTexture.html
Further to this, if you don't have Pro there's a script that achieves a similar effect without Pro on UnifyWiki: http://wiki.unity3d.com/index.php?title=RenderTexture_Free.
NB: The author warns that it's slow! But if you don't need this to refresh on Update, it may suit your needs.
I just tried RenderTextureFree(). The test program throws the error:
ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame.
$$anonymous$$odifying the test program as follows allowed it to work. There is probably a better way.
using UnityEngine;
using System.Collections;
public class RTtest : $$anonymous$$onoBehaviour
{
public float refresh = 1f;
void Start (){
StartCoroutine(SimulateRenderTexure());
}
IEnumerator SimulateRenderTexure(){
while (true) {
yield return new WaitForEndOfFrame();
renderer.material.mainTexture = RenderTextureFree.Capture();
yield return new WaitForSeconds(refresh);
}
}
}
Your answer