Search Unity

[Retargeting] Could Timeline Track/PlayableDirector binding keys be visible in the project view ?

Discussion in 'Timeline' started by Kiupe, Aug 17, 2018.

  1. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hello,

    In a current project I have a timeline that I want to play at different moments and different locations. That means that the context is different each time but the configuration is the same : there is always the main game character and an enemy and this is all the timeline need to work as expected.

    On my side, as a developer, I need to re-bind the "enemy" track with the current enemy using the
    SetGenericBinding method. What I find annoying is that the key is an object and that object we can't select it directly in the project view. Could be useful to be able to selecte a timeline track which is a binding key and assign it inside a Object field within a script.

    From a PlayableDirector using the debug view those objects are visible from the inspector but no way to really select them from the project view therefore no way to use them inside a custom script.

    I can use track name to find the right PlayableBinding but it's not really safe because the name could change and it's not as really useful as be able to directly target the key object.

    All that speech (I hope it does make sense) to ask if those object ( my understanding is that they represent timeline track) could be visible inside the project view as timelines are ?

    Thanks
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can make them visible as subassets of the timeline asset with the following script.

    Code (CSharp):
    1.     void ShowTimelineTracks (TimelineAsset asset)
    2.     {
    3.         if (asset)
    4.         {
    5.             foreach (var track in asset.GetOutputTracks())
    6.             {
    7.                 track.hideFlags &= ~HideFlags.HideInHierarchy;
    8.                 UnityEditor.EditorUtility.SetDirty(track);
    9.             }
    10.             UnityEditor.AssetDatabase.SaveAssets();
    11.         }
    12.     }
    13.  
     
    senkal_ likes this.
  3. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hello,

    First of all thank you.

    How that script get executed ? Where should I put this script on ?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Where ever it makes sense for your workflow. You could put it on a Monobehaviour on the same object as the playable director and have it apply automatically, or make a simple window with a button that takes a timeline asset. Or just a menu item that applies it to all timeline assets in project.