Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Custom PlayableAsset in Awake?

Discussion in 'Timeline' started by Neebz, Mar 12, 2020.

  1. Neebz


    Sep 25, 2017
    I'm currently making a custom VideoPlayer PlayableAsset and PlayableBehaviour etc. and unfortunately VideoPlayers need to prepare before playing, in order to play the same frame as the Play method is invoked. This is not a problem throughout a timeline where there is time before the videos need to play, but I cannot figure out how to make a video, which is at 0.0 time in a timeline prepare before it needs to play, as it seems the PlayableAsset is only creating the playable runtime (also explained in it's documentation), when the actual timeline is playing.

    I could just make a MonoBehaviour that does this, and put it on the VideoPlayer GameObject, but I'm trying to make it as straight forward to use as possible, so having exposed values in the PlayableAsset would be preferred.

    Any help is much appreciated : )
  2. seant_unity


    Unity Technologies

    Aug 25, 2015
    There are several approaches you could is one suggestion based on your description.

    If you are looking to delay the first frame of the timeline, you could call PlayableDirector.RebuildGraph() on one frame, and then Play() on the next frame, or whenever the video is ready.

    RebuildGraph will only create the playable graph, so, you could prepare any clips during construction of the graph.