Search Unity

Extend AnimationPlayableAsset

Discussion in 'Timeline' started by Antoine_OSG, Oct 16, 2017.

  1. Antoine_OSG

    Antoine_OSG

    Joined:
    Sep 2, 2016
    Posts:
    43
    Hello,
    I am trying to extend AnimationPlayableAsset in order to add a few features that are specific to my game into it (for example, I'd like to be able to add control on blendshapes on some animations, or other things like that).
    Most importantly, I'd like to be able to keep the ability to preview the animation on my character when using preview mode.
    For the moment, I am struggling with trying to inherit from AnimationPlayableAsset, but I am not even sure that is the right approach.
    Has anyone managed to do something like this already?
    Thanks in advance.
     
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    I would like this too.

    Unforunately the timeline feature isnt all it was cracked up to be, and because of the lackluster reception I have very little faith it will ever get "finished".

    Just look at the terrain system , or nested prefabs. Some things never get done, I worry this will become another semi integrated semi finished system that gets put to one side.
     
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    AnimationPlayableAsset wasn't originally intended to be extended, although that seems like a something that has been requested by several people.

    There are plans to give users more control over animation in general, and that will extend to timeline. The ground work for that is just starting now.

    As for worries that timeline will never be "finished", it has a dedicated team at Unity. It is actively being worked on and we are always looking for feedback to make it better.
     
  4. razveck

    razveck

    Joined:
    Jan 8, 2013
    Posts:
    6
    Bump.

    Any news on this functionality? I would like to extend the Animation Playable to add my own callbacks when Animations are played, blended or otherwise interacted with from the Timeline.
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The ability to extend AnimationPlayableAsset hasn't explicitly been worked on, but there are several things that have landed since the last post, or will land soon that will help.
    • Animation Events are now supported in timeline.
    • Animation C# Jobs were recently introduced. We are currently looking at integrating those into timeline. Not quite the callback mechanism, but it would be a way to inject into existing animation tracks.
    • You can create your own simple animation tracks. It can be useful where root motion and offsets that typically are needed with character animation aren't needed (UI for example). There you would have fully control over the resulting graph produced.
    • Playable Notifications in 2018.3 let you send notifications to a binding. This is a precursor to timeline events.
    I quickly tried extending AnimationTrack and AnimationPlayableAsset and injecting a simple script playable into the graph to get a clearer picture of what worked and what didn't, and on the surface it's possible to get something working. But the extended classes don't properly inherit a lot of the customization done for Animation Tracks, so they are more difficult to use (for example, the matching options aren't available and the inspector is not inherited).

    I'll post it here if you want to look at the methodology. I built it with 2018.3 (which has improved Animation Tracks).
     

    Attached Files:

    senkal_ likes this.
  6. razveck

    razveck

    Joined:
    Jan 8, 2013
    Posts:
    6
    After fiddling around with your examples I managed to make it work! Thanks a lot. I did it with 2017.4.10f1


    Now I have one further question:

    Right now I have to create an asset of CustomAnimationPlayableAsset type and then drag it/select it from the context menu). It would be nice to just either drag an animation and have it create a CustomAnimationClip instead of the default AnimationClip or alternatively be able to simply add a Clip and then assign the animation in its inspector (basically bypassing the whole creating an asset step).
    But since I haven't found a straightforward way to do this I assume it's due to some behind-the-scenes editor magic regarding the AnimationTrack. Any advice on this? Maybe this is possible in 2018.3 but we're unfortunately stuck with 2017.4 for now :(
     
  7. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Sorry, no way around that one :( 2018.2 has better drag and drop support and recognizes ExtendedAnimationPlayableAsset, but it prioritizes AnimationPlayableAsset over ExtendedAnimationPlayableAsset.
     
  8. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    thank's so have extention of AudioPlayableAsset

    but hope for better workflow and understand think's i do lol

    so need 2 think's is autosetup clip lenght

    and get clip name like base AudioPlayableAsset do by default

    or another way maybi
     
  9. FredZvtMC

    FredZvtMC

    Joined:
    Apr 18, 2019
    Posts:
    2
    I'm looking for a way to define (or change) the clip of an AnimationPlaybackAsset through script in runtime. Is that feasible?
     
  10. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes, it is. Here's an example that replaces them all.

    Code (CSharp):
    1. var timeline = (TimelineAsset) playableDirector.playableAsset;
    2. foreach (var track in timeline.GetOutputTracks().OfType<AnimationTrack>()
    3. {
    4.      foreach (var clip in track.GetClips())
    5.      {
    6.            var animPlayableAsset = (AnimationPlayableAsset) clip.asset;
    7.            animPlayableAsset.clip = myAnimationClip;
    8.      }
    9. }
    10.  
    11. playableDirector.RebuildGraph();

    Note that you are modifying the asset in this case, which even in playmode may get saved.
     
  11. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    437
    sorry to necropost this but has there been any progress with extending the animation playable for the timeline?