Search Unity

Adding a new type of clip to the AnimationTrack

Discussion in 'Timeline' started by rickknowles, Oct 4, 2019.

  1. rickknowles

    rickknowles

    Joined:
    Apr 21, 2018
    Posts:
    7
    Hi,

    Any suggestions greatly appreciated with tackling the problem below :)

    I'd like to be able to add an additional sort of AnimationClip to the default Timeline AnimationTrack (or at least something that behaves exactly like it).

    The AnimationTrack as it stands only supports adding from AnimationClip objects, and I have code that translates the other format I have into an AnimationClip object, but I'd like to be able to read directly from the custom clip format and perform the conversion just as it's being played back by timeline. Doing so will result in lots of reduced network transfer and disk space used for the people using the app.

    After trying to inherit from AnimationTrack, I discovered that the methods I planned on using weren't available (at least they weren't visible to the decompiler in visual studio). I'd thought about doing something like:

    Code (CSharp):
    1.  
    2.     public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    3.     {
    4.         return ScriptPlayable<MySubClassOfAnimationPlayableAsset>.Create (graph, inputCount);
    5.     }
    in MySubClassOfAnimationTrack, but then realized this was the mixer and I had no idea where to get the mixer implementation from.

    Does anyone have any idea where I could see the source for the unity timeline core track / behaviour implementations ? I'm happy to read through large amounts of source code to find where to hook in, but I can't find it online (the open reference source unity publishes doesn't cover timeline).

    Alternatively if anyone can suggest a method for supplying an in-memory AnimationClip object generated from another TrackClip type to the AnimationTrack please do.

    Thanks in advance,

    Rick
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    If you have 2019.1 or .2 the timeline source should be available inside your install folder under Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.timeline

    In 2019.3 it should be inside your projects package cache.

    As for the question, you can't override the mixer because an AnimationMixer needs to be used in an animation graph. You might be able to subclass AnimationPlayableAsset and override CreatePlayable and use an AnimationScriptPlayable (animationJob), although you may run into issues if you require root motion.

    Depending on your use cases, writing your own custom AnimationTrack may be an option as well.
     
  3. rickknowles

    rickknowles

    Joined:
    Apr 21, 2018
    Posts:
    7
    Magic - thank you, I'll take a look. I'm working in 2018.3, but even just reading the code for the 2019 might give me what I'm looking for without needing to upgrade. Thank you so much