I have a project where i’m projecting my device’s camera onto a plane using a webcamtexture. I’ve had it working before, but with unity 5 it keeps crashing whenever i press the play button. I have the following script on the plane.
using UnityEngine; using System.Collections; public class backgroundScript : MonoBehaviour { private WebCamTexture backgroundTexture; void Start () { backgroundTexture = new WebCamTexture (); backgroundTexture.requestedWidth = 1920; backgroundTexture.requestedHeight =
1080;
backgroundTexture.Play ();
GetComponent().material.mainTexture
= backgroundTexture;Debug.Log ("camera image width = " + backgroundTexture.width + " camera image height = " + backgroundTexture.height); //StartRecording (); } public void StartRecording(){ } public void StopRecording(){ backgroundTexture.Stop (); } }
I’ve also commented out the line: backgroundTexture.Play(); and it didn’t crash, so i’m assuming this is the cause of the problem.