I am unable to run the video. Here is the detailed definition. What should I write to run it?

After moving script file to plane, I get this debug output:

This is my debug output

Here is the code on my button which is related to the plane object:

using UnityEngine;
using System.Collections;

public class Button : MonoBehaviour
    public MovieTexture movie;

    void Start()
        GetComponent<Renderer>().material.mainTexture = movie as MovieTexture;

I am following this tutorial and getting an "Unassigned reference error".

  • \$\begingroup\$ Can you include the actual error as it appears? As it stands, it sounds like you might have declared public MovieTexture, but have not actually linked a movie texture via the inspector. \$\endgroup\$ – Gnemlock Sep 4 '16 at 1:43
  • \$\begingroup\$ unable to link it using unity ui it says None(Movie texture) \$\endgroup\$ – Rıfat Erdem Sahin Sep 4 '16 at 11:37


The Unity documentation is very good. To play videos in unity you must use a MovieTexture

The unity docs provides a lot more information, but I shall summarise it here.

How to

First import the movie file, this requires QuickTime

Video files are imported via Apple QuickTime. Supported file types are what your QuickTime installation can play (usually .mov, .mpg, .mpeg, .mp4, .avi, .asf). On Windows movie importing requires Quicktime to be installed (download here).

Then create a material for the movie and drag the movie asset to the texture argument (This albedo in the Unity 5 standard shader)

Drag that material onto the object you wish to show the movie on

Then add the following script to the game object which has the movie material on

// Use this for initialization
MovieTexture movie; //This is private as we get the movie texture from the renderer

void Start () {
    Renderer r = GetComponent<Renderer>(); //The renderer will give us access to the material
    movie = (MovieTexture)r.material.mainTexture; //Get the texture and cast it to a MovieTexture

    if (movie == null) //Check the texure exists and is a MovieTexture
        Debug.LogError("There is no movie texture on the material");
        Debug.Break(); //Pause the editor

// Update is called once per frame
void Update () {
    if (Input.GetKeyDown(KeyCode.Space))
        if (movie.isPlaying)
  • \$\begingroup\$ This appears to show only a more advanced implementation of what the asker is already doing. If calling movie.Play() doesn't work at all, checking if movie.IsPlaying first surely does nothing to help. In fact, the error code Unassigned Reference tells us the problem is unrelated. \$\endgroup\$ – Gnemlock Sep 4 '16 at 1:42
  • \$\begingroup\$ Gnemlock, I understand that, however it seemed the asker was very sketchy on what they currently had, so I have also explained how the the MovieTexture works inside unity and provided a doc link \$\endgroup\$ – Everless Drop 41 Sep 4 '16 at 8:58
  • 1
    \$\begingroup\$ getting object reference error. Renderer r = GetComponent<Renderer>(); MovieTexture movie = r.material.mainTexture as MovieTexture; movie.Play(); \$\endgroup\$ – Rıfat Erdem Sahin Sep 4 '16 at 11:33
  • \$\begingroup\$ public MovieTexture movie; after adding this it says none in the plane. \$\endgroup\$ – Rıfat Erdem Sahin Sep 4 '16 at 11:36
  • \$\begingroup\$ I've updated my answer - if you're still stuck I can add screenshots. Feel free to ask if there's anything you don't understand \$\endgroup\$ – Everless Drop 41 Sep 4 '16 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.