I am trying to use the webcamtexture to display a live feed of my web cam in unity. But when I execute the code the plane which the image should be displayed turns black and I get these errors:
The code is shown below:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class DisplayWebCam : MonoBehaviour {
void Start() {
WebCamTexture webcamTexture = new WebCamTexture();
Renderer renderer = GetComponent<Renderer>();
renderer.material.mainTexture = webcamTexture;
webcamTexture.Play();
}
}
I am using a xbox kinect 360 and it works in other applications, but not unity. I have made sure that the camera is not being used by other applications and the error is still present. I would use the NatCam, but for me $75 is quite expensive! Does anybody know what is causing the errors and how to fix them, so that the camera is displayed inside unity?
Any help is appreciated, many thanks.