Search Unity

how to update timeline in playmode when clips are added/deleted?

Discussion in 'Timeline' started by aivo, Feb 5, 2019.

  1. aivo

    aivo

    Joined:
    Feb 13, 2017
    Posts:
    30
    hello, there is another question which is bugging me.

    I have created some custom clips as well as my own MixerBehaviour.. looking more or less as follows:
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.Playables;
    4. using UnityEngine.Timeline;
    5.  
    6. public class ScreenClientMixerBehaviour : PlayableBehaviour
    7. {
    8.  
    9.     public override void OnPlayableCreate(Playable playable)
    10.     {
    11.  
    12.         // doing stuff
    13.     }
    14.     public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    15.     {
    16.      
    17.         // doing more stuff
    18.     }
    19. }

    Say I have some tracks with some clips on it.
    In Play Mode, when I move the clips around, it takes effect as expected (in my case some properties are set according to the clips position on the timeline). But when I remove a clip, the clip still seems to be on the timeline internally, although not visible anymore (the properties are still being set). Similar to this, when I add a clip, there is no effect (no properties are set where the new clip lies).


    I realize when adding/removing clip on the timeline
    public override void OnPlayableCreate(Playable playable)
    is being called and thus adding internally the clips for each playable. How can I call this function during play mode? Or is there another way to have the timeline update its interal clip list?

    interestingly though I can get the tracks as well as the clips by iterating through PlayableDirector.playableAssets, but this doesn't have any effect on the timelines playables..

    EDIT: hm.. I just found out that I actually can trigger OnPlayableCreate() by rebuilding the graph by PlayableDirector.RebuildGraph(). But unfortunately that didn't solve the issue of not being able to have added/removed clips taking effect during play mode..
     
    Last edited: Feb 5, 2019