I'm trying to display web camera input on scene, using WebCamTexture
. I've created a Sprite with some default texture and attached following script to it:
public class CameraTexture : MonoBehaviour {
void Start () {
WebCamTexture webcamTexture = new WebCamTexture();
renderer.material.mainTexture = webcamTexture;
webcamTexture.Play();
}
}
But, when I run the scene (on PC), the camera input isn't displayed, only the default texture. Here is what I know:
webcamTexture
isn't null, the device is properly foundWhy is the camera input not displayed?
I've found a solution myself.
The webcamTexture
cannot be displayed on Sprite.
I had to create a GUITexture instead, then I attached the same script and everything worked fine.