How to get the TimelineClip for a PlayableBehaviour?

I have a PlayableAsset that puts a PlayableBehaviour on a Timeline. Now I would like to automatically change the duration of the resulting TimelineClip in CreatePlayable() in my PlayableAsset.

How do I get to the resulting TimelineClip?

There’s no reference to the TimelineClip from a PlayableAsset. However, if you have a custom track, you can override CreateTrackMixer(), and iterate through the clips of the track there.

The track mixer is created prior to the clip playables, so you should be able to make any adjustments you need there.

Thanks! Now I made it work with a custom track!

How can I iterate through my type of behaviors to access their data during building stage? I can’t find any example on how to get externally to actual behaviors and their data (not the templates).

I solved it.
You just to have iterate through the assets.

       //Timeline
        string[] guids = AssetDatabase.FindAssets("t:TimelineAsset");
        foreach (string guid in guids)
        {
            TimelineAsset timeline = (TimelineAsset)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(TimelineAsset));

            foreach( var track in timeline.GetOutputTracks() )
            {
                foreach (var clip in track.GetClips())
                {
                    if( clip.asset.GetType() == typeof(MyType) )
                    {
                        MyType mt = (MyType)clip.asset;
                    }
                }
            }
        }
1 Like

The problem with this is that it won’t build because AssetDatabase is a part of UnityEditor and that’s simply not available in a build… :confused:

you can use Resource or AssetBundle to load.Then use this way to do what you want