Proper way to manage multiple timeline ?

In my case, I'm using timeline to create animation for character skill, so I can manage all the collider and effects object in the same timeline. But, because I got multiple skill, I've created multiple playable asset and using script to assigning the Director to play them. But if I do this, I need to manually select the playable asset from "Playable" inspector when I need to edit the others timeline (Because I can't have multiple director component or playable asset) , it still works but doesn't seems like a proper way. (feels like cheating :3 )

Did I miss out somethings important ? Or did I used a overpowered way ? Suggestion would be appreciate. Thanks

You can edit the timelines by clicking on the timeline asset in the project window, but you won't be able to assign bindings, preview, or do anything that requires a scene context.

Or each timeline can have it's own playable director component in the scene, and your script can just access the different directors.

Those might be easier workflows.

Ya that sounds more easy to manage, thanks for the suggestion : )

Since there is a Timeline selection dropdown I thought you would be able to select all compatible Timelines, but I guess defining compatibility is not easy, so we end up with only one choice possible.

3542957--284521--upload_2018-6-24_19-43-0.png

That still seems the ideal place to put other Timeline candidates (think the Animator view where all Animations used at least once in the Animator Controller can be switched to with a dropdown).

I was watching this video:

https://www.youtube.com/watch?v=cmExSYI2yd0|start=256

and there is an ellipse just when the speaker changes Timeline. It looked like he uses a dropdown but now I'm almost sure there is an ellipse because he had to drag and drop the Timeline and it took some time to find the asset in the Project.

That said, I understand the difference between the Animation dropdown, which doesn't change the state of the object (the Animator Controller remains the same) and the Timeline dropdown I suggest, which would change the TImeline reference on the active Playable Director and make it dirty. So I guess using the Playable object picker is the more appropriate way since it shows to the user that the object's state has changed.

However, I still wonder why there is a Timeline dropdown at all, if only one can be selected at a time?

1 Like

Just like @009 I am using timelines for character actions. Orchestrating animations, sounds, effects and also logical events at specific points in time is great this way. But editing a set of a few dozen skills becomes time consuming, because switching between them requires me to find the asset in the project view first. I would love it when the workflow here could be improved.

Individual PlayableDirectors for each skill is not an option for me. The PlayableDirector must be attached to the character, because it is instantiated from a prefab. Selecting the timeline asset in the project view prevents playback. And as @seant_unity says, references cannot be edited this way, because the PlayableDirector holds that state.

As @huulong says, there is a dropdown which could offer this possibility. Currently, you can use it to switch between different PlayableDirectors that are in the scene/prefab. The PlayableDirector already holds a list of PlayableAssets for which it defines bindings. So it should be possible to make those accessible via the dropdown, or am I wrong?

What I'd do is make a custom 'skill editor' editor window that displays a list of playable directors in the scene, you can use GameObject.FindObjectsOfType() to get a list of playable directors and use this as a shortcut picker

Hi, thanks for your reply.
Well, there is only one PlayableDirector, but it will play different timeline assets, using PlayableDirector.Play(PlayableAsset).
I would love to build a custom editor window, that would show all PlayableAssets that the selected PlayableDirector has bindings for. The PlayableDirector does have bindings for all these PlayableAssets. This is serialized as m_SceneBindings and from the respective guids it should be possible to figure out the PlayableAssets. Only I don't know how to access that, otherwise I could help myself. The dropdown in the timeline window unfortunately only offers those that are currently assigned to some PlayableDirector in the scene. But I need those that have configured bindings but are not currently assigned to any PlayableDirector. This would be similar to the Animation window where there is a dropdown with all Animations that are assigned to some state of the Animator.
Does this make sense?

a playable director can only have bindings to a single asset at a time - if you are dynamically swapping the asset that it is bound to then you'd want to do basically the same thing that I suggested, except instead of storing a list of playable directors, you'd store a list of the 'skill assets' and dynamically update the playable director's asset entry and refresh the timeline window to display the updated asset info.

The bindings themselves however are stored in the scene / prefab so you'd have to store the 'last known bindings' and reconnect them dynamically as well (which is definitely doable in theory).

Either way, this would require custom tooling for this use case.

Actually, a playable director retains bindings from all timelines that have been assigned to it, but the inspector only displays the bindings for the currently assigned timeline, unless you use the debug inspector. The retaining of the bindings was intentional for the use case of swapping timelines easier - but this can also be problematic in that there are hidden asset references.

And, as Mike points out, if you are using prefabs it only retains bindings for items in the prefab.

And as @olejuer points out, there is no API to query which bindings it has. If you know the timeline asset, the binding key to GetGenericBinding is simply the track, and you can iterate on those using timelineAsset.GetOutputTracks(), even if the timelineAsset is not currently assigned as the main timeline.

An additional Monobehaviour / window that holds all the timelines might work to quickly switch timelines on a playable director - I'm not sure if the timeline editor will handle the case where the timeline asset is swapped out on the playable director. Might need to unload/reload the playable director in the timeline editor for it to update properly.

1 Like

Hi,

thank you @seant_unity ! With that information I was able to extend the inspector of PlayableDirector to show all TimelineAssets it has bindings for. Here it goes, works like a charm so far

public class PlayableDirectorInspector : UnityEditor.Editor
{
    private TimelineAsset[] _timelineAssets;

    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        EditorGUILayout.LabelField("Configured Timelines", EditorStyles.boldLabel);
        var playableDirector = serializedObject.targetObject as PlayableDirector;
        if (playableDirector == null) return;
        _timelineAssets = _timelineAssets ?? Resources.FindObjectsOfTypeAll<TimelineAsset>();
        TimelineAsset[] configuredTimelines = _timelineAssets
            .Where(timelineAsset => timelineAsset.GetOutputTracks()
                .Any(track => playableDirector.GetGenericBinding(track) != null))
            .ToArray();

        foreach (TimelineAsset timelineAsset in configuredTimelines)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUI.enabled = false;
            EditorGUILayout.ObjectField(timelineAsset, typeof(TimelineAsset), false);
            GUI.enabled = true;
            if (GUILayout.Button("Select"))
            {
                playableDirector.playableAsset = timelineAsset;
                TimelineEditor.Refresh(RefreshReason.ContentsModified);
            }

            GUILayout.EndHorizontal();
        }
    }
}
2 Likes

Looks like this and can be used to quickly navigate to the TimelineAsset or select it, which refreshes the Timeline window:
5681083--592612--upload_2020-4-7_15-17-28.png

2 Likes

nice! very cool

Proper way to manage multiple timeline ?
The answer cannot understand for me. Pls anybody show a answer in flow diagram or any video. pls, help me guys

unity technologies pls next time upload a videos to give a proper explanation.Because the beginners are very struggle for your explanation.

1 Like

wtf

3 Likes