I have a UI with a button and a panel. Clicking the button toggles the panel on and off :


Now the panel element has a child which is a plane. This plane has the following components :

  • mesh renderer
  • videoPlay, a script I've written
  • an audio source

The videoPlay script basically applies the MovieTexture to the plane's material, sets the plane's audioSource to the movie's audio clip, and starts audio and video.

public MovieTexture movie;

void Start() {
    GetComponent<Renderer>().material.mainTexture = movie as MovieTexture;
    GetComponent<AudioSource>().clip = movie.audioClip;

Now when at runtime I click the button (which hides the panel which is the plane's parent element), the audio and video stop as the plane disappears - which is expected behaviour.

When I reopen the panel though, the sound restarts right away but as if it were catching up for the time it was hidden (so it starts really fast and then comes back to regular speed) ; and the video is just frozen for - empirically and approximately - the same time the panel was hidden.

I've tried in the script - in Update() - messing with

if (!transform.parent.gameObject.activeSelf && movie.isPlaying)

for example, (and the same with Play() when it shows back up) but it doesn't seem to change anything.

  • \$\begingroup\$ You need to pause before you de-activate the gameobject, not after. \$\endgroup\$
    – jgallant
    Commented Apr 5, 2017 at 17:18
  • \$\begingroup\$ Makes sense. I'll add a script to the button to make the toggle (right now I'm using unity itself), and play/pause appropriately. \$\endgroup\$
    – Saryk
    Commented Apr 5, 2017 at 17:22
  • \$\begingroup\$ If that solves the issue, make sure to add it as an answer and (after the required delay) mark it accepted - that will make it easier for other users with similar problems to find the solution. \$\endgroup\$
    – DMGregory
    Commented Apr 5, 2017 at 19:40

1 Answer 1


As @jgallant stated, it was a matter of pausing the A/V before deactivating the panel.

I rearranged the scripts and works fine, still with a small delay though.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .