Hello all,
I wish someone could help me with this. I am using a movie texture to play my video on a GUI button click.But it only plays one time,the first time I click the button.How do I get it to play again.
Im sure Im doing something wrong here, but I really don’t know what else to do…
I am using:
var movTexture : MovieTexture;
var cubeRenderer:Renderer;
var playAutomatically : boolean ;
function OnGUI()
{
if(GUI.Button(Rect(10, 10, 150, 20), "PLAY"))
renderer.material.mainTexture.Play();
if(GUI.Button(Rect(10, 30, 150, 20), "Back to main"))
Application.LoadLevel("MainLevel");
}
function Update () {
if (GUI.Button(Rect(10, 10, 150, 20), "Play")) {
if (renderer.material.mainTexture.isPlaying) {
renderer.material.mainTexture.Pause();
}
else
{
renderer.material.mainTexture.Play();
}
}
}
It wont play again,only once, plus, there is a ArgumentException saying: You can call GUI functions from inside OnGUI.
I would really appreciate any help I could get about this.
Thank you in advance!!!
In your code you have the MovieTexture var movTexture : MovieTexture; So if you assign the movie texture you wan't to control to that variable then you just have to call the function from it i.e. movTexture.Play(); movTexture.Stop();
– tnetennba