I have this painting object with a Movie attached to it as a material. At the bottom I initialize all objects with a tag “Painting”. I also initializes the external script named “GalleryGUI”.
function Awake()
{
detectedObject=GameObject.FindWithTag("Paintings");
galleryGUI=gameObject.GetComponent(typeof(GalleryGUI)) as GalleryGUI;
paintings = GameObject.FindWithTag ("Paintings");
}
in GalleryGUI, there is a variable name Movie, with a type of MovieTexture.
So I called the Movie variable and assigned the variable to the painting’s material.
So I have this variable with a type of MovieTexture
//Create a movie variable type MovieTexture. This variable will holds the movie material.
var movie:MovieTexture;
//This is the GUI layout and functions of the Video Player.
function VideoWindowGUI (windowID : int) {
//Create a GUI to display the movie or video
myVideo.DrawTexture(new Rect(Screen.width*0.5-Screen.width*0.25, Screen.height*0.5-Screen.height*0.35, Screen.width*0.5, Screen.height*0.5), movie);
//Create 4 GUIs
//Pause, Play, Stop, Quit
if (GUI.Button (getPlayButtonSize(), "Pause"))
{
movie.Pause();
}
if(GUI.Button(getPauseButtonSize(),"Play"))
{
movie.Play();
}
if(GUI.Button(getStopButtonSize(),"Stop"))
{
movie.Stop();
}
if (GUI.Button (getExitButtonSize(), "quit"))
{
movie.Stop();
menuTrigger=true;
videoTrigger=false;
}
}
I would like to assign the movie variable to a material of another object.
You are trying to assign a material to a texture, but the two aren’t the same. A material actually has a texture property called mainTexture that you should use:-