Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Why can't I drag a TimelineAsset onto a timeline?

Discussion in 'Timeline' started by CDF, Feb 15, 2024.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,324
    In
    TimelineDragging
    there's this method:

    Code (CSharp):
    1. static bool ValidateObjectDrop(UnityObject obj)
    2. {
    3.     // legacy animation clips are not supported at all
    4.     AnimationClip clip = obj as AnimationClip;
    5.     if (clip != null && clip.legacy)
    6.         return false;
    7.  
    8.     return !(obj is TimelineAsset); //WHY?
    9. }
    Why are TimelineAssets not allowed to be dragged onto a timeline?

    I have a custom track that builds playables from a timeline asset:

    Code (CSharp):
    1. [TrackClipType(typeof(TimelinePlayableAsset), false)]
    2. [TrackBindingType(typeof(GameObject), TrackBindingFlags.None)]
    3. public class TimelineAssetTrack : PlayableTrack {
    4. }
    5.  
    6. public class TimelinePlayableAsset : PlayableAsset, ITimelineClipAsset {
    7.  
    8.     public ClipCaps clipCaps => ClipCaps.None;
    9.  
    10.     public override double duration => asset != null ? asset.duration : base.duration;
    11.  
    12.     public TimelineAsset TimelineAsset => asset;
    13.  
    14.     [SerializeField] public TimelineAsset asset;
    15.     [SerializeField] public PlayableTraversalMode traversalMode = PlayableTraversalMode.Mix;
    16.  
    17.     public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) {
    18.  
    19.         if (asset == null) {
    20.             return Playable.Create(graph);
    21.         }
    22.  
    23.         Playable playable = asset.CreatePlayable(graph, owner);
    24.         playable.SetTraversalMode(traversalMode);
    25.  
    26.         return playable;
    27.     }
    28. }
    I want the ability to drag a TimelineAsset onto my track and have it create a clip.
    That
    ValidateObjectDrop
    method is preventing me from doing so.

    If I embed the timeline package locally and return true from that method. I'm able to create clips on my custom track fine. I don't understand why this functionality is disabled