- Home /
webcamtexture makes unity 5 crash
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<Renderer>().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.
Answer by chelder · Oct 19, 2015 at 11:21 AM
You have helped me to find the solution. In my case, it crashed the second time backgroundTexture.Play();
was called.
So the solution was to make sure that backgroundTexture.Stop ();
was being called before the second time.
I'm on Unity 5.2.0f3 Personal.
Your answer
Follow this Question
Related Questions
How to make a WebCamTexture 'run'? 0 Answers
How to record a webcam stream to a file on the server? 0 Answers
Unity Webcamtexture Camera very slow when using markerless ar unity asset 0 Answers
Webcam Image Causes Unity 5 to Crash!! 0 Answers
Cam texture stopped working in Unity 5/Android Lollipop 0 Answers