How can I assign a Movie Texture variable to a material

Hi

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.

var movie:MovieTexture;
galleryGUI.movie=GameObject.renderer.material;

It gives me an error like

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.

I tried this, but it does not work.

movie=GameObject.GetComponent(typeof(MovieTexture));

In a simple term I have this Object name “2” having two materials attached to it.
One is the Diffuse material and the other is the Movie material.

I have this script with a variable

var movie:MovieTexture

I want to assign the GameObject 2’s movie material to the movie variable through a javascript.

Is there any possibility to do this. Please help me.

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:-

galleryGUI.movie=gameObject.renderer.material.mainTexture;

(Note also that you need a lowercase G on “gameObject” in this case.)