Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

How to delay a playable

Discussion in 'Timeline' started by khan-amil, Aug 4, 2022.

  1. khan-amil

    khan-amil

    Joined:
    Mar 29, 2012
    Posts:
    206
    One of my custom timeline behaviour create internally a number of playables and bundles them up in a mixer in the CreatePlayable phase. I've took inspiration from the control track code and it's working well.

    However I'd like to delay a bit these events so that they don't all play at once. "PlayableExtensions.SetDelay()" seemed to be exactly what I wanted, but it's marked as obsolete with the advicce to handle it with a custom scriptable. I have a hard time trying to wrap my head around this being not familiar with the playable API, I can't get to "chain" playables, unity always complaint when I try to connect more than one :

    Here is my code (for now just trying to delay the whole mixer)
    Code (CSharp):
    1. public static Playable CreateMixerFromPlayables(PlayableGraph graph, List<Playable> playables)
    2.         {
    3.             // Create mixer behaviour
    4.             Playable mixer = Playable.Create(graph, playables.Count);
    5.  
    6.             // Connect each playable to the mixer with same weight
    7.             for (int i = 0; i != playables.Count; ++i)
    8.             {
    9.                 // Connect this playable in mixer's input port i
    10.                 ConnectMixerAndPlayable(graph, mixer, playables[i], i);
    11.             }
    12.  
    13.             // Create a playable to delay the whole mixer
    14.             Playable premixer = Playable.Create(graph, 1);
    15.             // Set delay duration
    16.             premixer.SetDuration(5);
    17.             // Connect mixer to premixer input
    18.             graph.Connect(mixer, 0, premixer, 0);
    19.  
    20.  
    21.             premixer.SetPropagateSetTime(true);
    22.             mixer.SetPropagateSetTime(true);
    23.  
    24.             return mixer;
    25.         }