Simple Movie loop Question

Hello and thanks in advance

Just trying to get a movie texture to Loop

What do i need to add, thanks.

function Update () {
if (Input.GetButtonDown (“Jump”)) {
if (renderer.material.mainTexture.isPlaying) {
renderer.material.mainTexture.Pause();
}
else {
renderer.material.mainTexture.Play();
}
}
}

I would love to know the answer to this as well. For the love of me I can’t get it to work. :cry:

var movieTexture : MovieTexture;

function Start() {
movieTexture.loop = true;
renderer.material.mainTexture = movieTexture;
movieTexture.Play ();
}

and then add your own stuff…

MovieTexture.loop seems the way to go and it’s easily found in the docs.

Finally Someone Made sense. God Bless You :slight_smile: WOOT!!!

well i have copied this code and it is not working for me. What do you mean by add your own stuff. >>>???

What is it doing or not doing? I believe “add your own stuff” simply implies to carry on with your development, as that’s probably not the entire game :slight_smile:

Did you follow the link that HiggyB provided to the documentation on it by chance?

~Scorp

Simple way and it doesent need any “own stuff”

// this line of code will make the Movie Texture begin playing
renderer.material.mainTexture.Play();
renderer.material.mainTexture.loop = true;

1 Like

Thank you… simple and worked like a charm… so easy even an artist can do it :wink:

Thank you!!!

Update.

My sound went out of sync after I made this script change.

Haven’t fixed it yet.

Update. Changed play audio script to match play movie script and unchecked “loop” in Editor.

Sometimes when I export to web player it works perfectly and sometimes it’s way out of sync.

When it’s out of sync I restart Unity and try again and that seems to fix it for that export.

Go figure.

Excuse my noobiness, I’ve only just started using C# and it’s my first programming language. I’m a bit confused which part is meant to call for the .mov file. I’m working in a 2D project and assume I should be applying this like a texture to a sprite. How far off am I? All input appreciated.

using System.Collections;

public class ExampleClass : MonoBehaviour {
public MovieTexture movTexture;
void Start() {
GetComponent<Renderer>().material.mainTexture = movTexture;
movTexture.Play();
}
}