[SOLVED]my original texture change to movie texture

hello everyone…here’s my case…ill provide some picture what actually happen to my project…first picture show my original texture of sphere…when i click the object it will show guibox that show movie texture there(picture 2)…after i play and stop it show my sphere like in picture 2 beside my pop guibox… here my my code so far…everything fine except the material changed after i play the video…help me plzz

picture 1 : 33909-1.jpg

picture 2 :

using UnityEngine;
using System.Collections;

public class eq1 : MonoBehaviour {
	
	// Use this for initialization
	private bool PopUp;
	public string Info;
	public MovieTexture movie_eq1;

	void OnMouseDown()
	{
		PopUp = true;

	}
	
	void DrawInfo()
	{
		//Rect rect = new Rect (20,20, 600, 400);
		Rect close = new Rect (800,20,20,20);
		Rect play = new Rect (100, 360, 50, 25);
		Rect pause = new Rect (150, 360, 50, 25);
		Rect stop = new Rect (200, 360, 50, 25);

			
		if (PopUp)
		{
			//content
			GUI.Box(new Rect(20, 20, 800, 400), "Weigh Machine");
			//GUI.Box(rect, Info);
			GUI.DrawTexture(new Rect(30, 50, 400, 300), movie_eq1);




			//playbutton
			if (GUI.Button(play,"play"))
			{
				//Debug.Log("playvideo");
				renderer.material.mainTexture = movie_eq1;
				movie_eq1.Play();
			}
			//pause
			if (GUI.Button(pause,"pause"))
			{
				renderer.material.mainTexture = movie_eq1;
				movie_eq1.Pause();
			}
			//stopbutton
			if (GUI.Button(stop,"stop"))
			{

				movie_eq1.Stop();
			}
			//guiTexture.texture.Play();
			if (GUI.Button(close,"X"))
			{
				PopUp = false;
				movie_eq1.Stop();
				//Debug.Log("close");
			}
		}
	}


	void OnGUI()
	{
		DrawInfo();

	}
}

help me plzz

1 Answer

1

I’m not completely clear on what you are asking. You don’t want the texture of the sphere to change at all? then at:

 if (GUI.Button(play,"play"))
             {
                 //Debug.Log("playvideo");
               renderer.material.mainTexture = movie_eq1;
                 movie_eq1.Play();
             }
             //pause
             if (GUI.Button(pause,"pause"))
           {
                 renderer.material.mainTexture = movie_eq1;
                 movie_eq1.Pause();
             }

Remove the 2 “renderer.material.mainTexture = movie_eq1;” as they are giving your sphere the movie texture.

If you want the texture to be on the sphere, but return to your original texture on close:

private Texture origTexture;

void Start () {
	origTexture = renderer.material.mainTexture;
}

…and then further down in your close button:

		if (GUI.Button(close,"X"))
		{
			PopUp = false;
			movie_eq1.Stop();
			renderer.material.mainTexture = origTexture;
		}

So it basically saves the original texture, and gives it back to the sphere when you close the movie.

thnks man..i love u..haha..i just don't want the texture of the sphere to change to movie texture at all..so i just delete render code as u mention above..it work..hehe.. SOLVED

Can you mark the correct answer as a solution? Then it won't show up in the unanswered queue anymore.

done..thnks..sorry im newbie here..