Search code examples
videounity-game-enginemovie

What I need to use in my coding if I didn't want my movie to play automatically?


Okay what I wanted to do is to not play the video by itself when the game is running, but player need to left click the video in order to play the video. It seems that when I started the game, the video play by itself.

1st Method.
I tried to use ,

movie.Stop(); //not in the if else statement

but that doesn't seems to work out, the movie stop and when I left clicked the video won't play anymore.

2nd Method
I tried using

movie.Pause(); //not in the if else statement

but that seems work, but when I click the video, the video tend to play frame by frame.

Example of my code:

public MovieTexture movie;
private AudioSource audio;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

    GetComponent<RawImage> ().texture = movie as MovieTexture;
    audio = GetComponent<AudioSource> ();
    audio.clip = movie.audioClip;
    movie.Play ();
    audio.Play ();

    if (Input.GetMouseButtonDown(0)&& movie.isPlaying)
        movie.Stop ();
    else if (Input.GetMouseButtonDown(0) && !movie.isPlaying)
        movie.Play ();  
}

Solution

  • setup a trigger, or i think unity calls it an "Event"