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().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.

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.