- Home /
how to make a plane display what a camera is capturing?
so i want to make an object like a plane or a face in a cube or something display what a camera is capturing, to make a security system, but i have no idea if its possible. if someone could tell me if its possible and hopefully link me to a tutorial, that would be great. thanks
Answer by vvkkumar06 · May 24, 2014 at 05:07 PM
Look at the below link it will help you.
http://docs.unity3d.com/Documentation/ScriptReference/Camera.Render.html http://answers.unity3d.com/questions/477888/texture-showing-camera-view.html
@vvkumar06 - are you sure this is what you are looking for? From your description, I though you wanted to pull in a video feed from an external camera. The above are showing Unity cameras in the scene.
Answer by lolmaster2 · Mar 15, 2017 at 09:08 PM
Try this code attached on your Plane and it will display your webcam on it. It does so by replacing the material of the plane with a WebCamTexture material.
using UnityEngine;
public class DisplayWebcam : MonoBehaviour {
void Start() {
Debug.Log("DisplayWebcam Initialize");
// Transform values of the plane to get you started:
// position 0 0 200
// rotation 90 180 0
// scale 80 1 40
var devices = WebCamTexture.devices;
var backCamName = "";
if(devices.Length > 0) backCamName = devices[0].name;
for(int i = 0; i < devices.Length; i++) {
Debug.Log("Device:" + devices[i].name + "IS FRONT FACING:" + devices[i].isFrontFacing);
if(!devices[i].isFrontFacing) {
backCamName = devices[i].name;
}
}
var CameraTexture = new WebCamTexture(backCamName, 10000, 10000, 30);
CameraTexture.Play();
var renderer = GetComponent<Renderer>();
renderer.material.mainTexture = CameraTexture;
}
void Update () {
}
}
The image is upside down so I rotated the plane 180 degrees