Webcam texture Error

Hello,

I would like to use Full camera screen for my gameplay area.
I am getting error in my webcam scripts.
Here is my code

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class webcamC : MonoBehaviour {
    GameObject cube;
    WebCamTexture web;
    // Use this for initialization
    void Start () {
        web = new WebCamTexture ();
        cube.texture = web;
        cube.material.MainTexture = web;
        web.Play ();
    }
   
    // Update is called once per frame
    void Update () {
   
    }
}

I tried this, and it works:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class webcamC : MonoBehaviour {

    public MeshRenderer cubeMR;
    WebCamTexture web;

    // Use this for initialization
    void Start () {
        web = new WebCamTexture ();
        cubeMR.material.mainTexture = web;
        web.Play ();
    }

    // Update is called once per frame
    void Update () {

    }
}

Be sure to drag your cube onto the cubeMR field.

Nice simple compact code. Thanks I know you could do this with unity but I thought that the code would be very complicate.