Search Unity

MovieTexture question/Problem

Discussion in 'Editor & General Support' started by Butterworth, Aug 10, 2013.

  1. Butterworth

    Butterworth

    Joined:
    Aug 8, 2012
    Posts:
    25
    Hello.

    I am using Unity's MovieTexture class to display movies on objects in a 3D scene. The one problem that I cant seem to solve is:

    When you start a movie, if the movietexture is already visible, it will not display anything for several frames until the first frame is decoded and then transferred to the texture.

    Is there some way I can initialize the MovieTexture's texture buffer with a texture copy of the first frame of the movie? The texture2D class can copy pixels to and from its buffer but the MovieTexture class doesnt support this.

    The only hacky solution I have gotten working so far is when a MovieTexture is loaded, while not visible (during level load) I play and wait several frames until I am sure the first frame is decoded, then I stop the movie. This works in most cases, but some movies will advance further than other thereby filling the texture buffer with frame 2 or 3 instead of frame 1. This causes the movie to jump when it finally starts playing. I might add that one person suggested playing the movie until "isPlaying" returns true, but this returns true several frames before any data appears in the texture buffer.

    I should add that my objects and movietextures are being generated during load time. I say this because I noticed that if I build the objects into the scene and apply the movies, it seems to properly preload the first frame into the texture buffer automatically. This is not an option for me, my game is entirely data driven from XML files.

    While on the topic of MovieTexture, it would be really amazing if the Unity folks could added some basic frame controls like GetCurrentFrame() or ForceFrame(int)

    Any advice will be appreciated.