Search Unity

Cannot record animation for custom track

Discussion in 'Timeline' started by olejuer, Apr 9, 2020.

  1. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    Hi,

    I am trying to animate a custom PlayableAsset on a custom TrackAsset with Timeline, but the record button does not appear on the track. Just to make sure I did not make a stupid mistake, I followed the guide from this blog exactly https://blogs.unity3d.com/2018/09/05/extending-timeline-a-practical-guide/ .
    Weirdly, I can create an animation clip by going "rightclick->Add Key" on the template field of the clip, though. I can view the curves in the timeline editor, but I cannot record. I tried to work around it by adding the animation to an AnimatorController, but that would not work either.
    Also, for the build-in AnimationTrack, I can record animations just fine.

    Is this a UI bug, or am I missing something? Working with Unity 2019.3.9f1. Thanks!

    upload_2020-4-9_11-41-48.png
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    We removed the record button in 2019.3, but added the ability to key from the menu or directly edit curves in the curves editor. The fields that can be animated automatically are also now displayed in the left side panel.
     
    olejuer likes this.
  3. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    Okay, understood, I guess there are good reasons for that. I think, the feature to create animations is a bit hidden now, though. After adding a key, one can double click to open the animation window for editing, so that's nice.

    Maybe I can misuse this here to ask another question. There is quite some boilerplate involved when creating new tracks and playables. Are there plans to add some more abstractions to handle this?

    I tried to build some abstraction layers to get rid of redundant code, but it is not easy from down here. For example, I built a class like this

    Code (CSharp):
    1. public abstract class PlayableAsset<T, TBehaviour> : PlayableAsset
    2.     where TBehaviour : PlayableBehaviour<T>, new()
    3.     where T : Component
    4. {
    5.     [SerializeField] private TBehaviour _template;
    6.     protected TBehaviour Template => _template;
    7.  
    8.     public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    9.     {
    10.         return ScriptPlayable<TBehaviour>.Create(graph, _template);
    11.     }
    12. }
    which helps, but unfortunately, animating an inherited template field does not seem to work. Timeline does not offer curves in this case.
    PlayableBehaviour<T> handles casting playerData to a specific type T and adding methods like OnPlayableStart() and OnPlayableStop().

    Are there any plans in that direction or am I misusing the entire Timeline concept?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    There isn't plans right now -- part of the reason for some of the boilerplate are due to limitations in the serialization system. 2019.3 added polymorphic serialization, which has the potential to help here, but I don't believe it supports generics yet.
     
    olejuer likes this.
  5. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    Okay, thanks. The serialization system is a bit of a downer sometimes :) Overall Timeline is really great, though, as is your support. Thanks again and happy easter
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Thanks, you too.