Search Unity

  1. Going to #UniteBerlin? Bring a buddy & get 25% off the 2nd ticket! More info here.
    Dismiss Notice
  2. Famed game designer and creator of The Sims, SimCIty, and Spore is looking for a 3D artist to join their team. Join the challenge.
    Dismiss Notice
  3. Unity 2017.4 has arrived! Read about it here.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. We've opened a new World Building sub-forum to faciltate all your world building discussions! Drop in and ask any ProBuilder, ProGrids, or PolyBrush questions.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Animation Curves on non-external animations

Discussion in 'Animation' started by VergilUa, Apr 16, 2018 at 1:13 PM.

  1. VergilUa

    VergilUa

    Joined:
    Dec 22, 2014
    Posts:
    279
    Hi guys. I'm wondering, is there a way to set an custom data animation curve at native animation?
    The one that isn't imported via external files (.anim files).

    In a same way as:
    https://docs.unity3d.com/Manual/AnimationCurvesOnImportedClips.html

    I can't find anything relevant on the topic.
    I cannot use default imported ones, because I need to change some properties on them.
    But at the same time I cannot add animation curves for my footsteps blend tree.

    I've tried first adding animation curves to the .fbx import settings, and then duplicating them, but the curves doesn't transfer that way. Maybe I'm doing something wrong.

    Any suggestions would be appreciated.
     
    Last edited: Apr 16, 2018 at 2:12 PM
  2. VergilUa

    VergilUa

    Joined:
    Dec 22, 2014
    Posts:
    279
    After some digging into sources and reflection, I've found out that for some reason m_ClipInfo of AnimationClipEditor is never actually assigned inside of it. That's why CurveGUI() is never drawn for a separate .anim files.

    This is either by design, or a bug. But it definately feels like some one was just too lazy to make another .Get() for an actual serializedObject inside AnimationClipInfoProperties.

    Some official info would be great.
    I don't really know who's writing UI for AnimationClip component.
    Maybe @Mecanim-Dev can help solving this one.
     
    Last edited: Apr 16, 2018 at 7:57 PM
  3. VergilUa

    VergilUa

    Joined:
    Dec 22, 2014
    Posts:
    279
    Figures out Unity stores two different types of animation clips.
    The one that's imported from model is called ModelImporterClipAnimation, and the actual created duplicate of that is AnimationClip, which doesn't even contain curves data property.

    AnimationClipInfoProperties are used specificly for the ModelImporterClipAnimation, and not the AnimationClip. So using an AnimatorClipEditor for those purposes are no go unfortunately.

    Best solution I guess would be either somehow create a data set / ScriptableObject that stores that information (curves, events etc) from ModelImporterClipAnimation when it's duplicated into AnimationClip and then also apply that.

    Unfortunatelly I'll be left with the same problem again, impossibility to actually edit curves. Maybe there's a different option. I guess I need to investigate how the actual curves are applied to the AnimationClip itself, when ModelImporterClipAnimation is used.

    Maybe there's an asset already that does the same, of which I'm not aware of?

    (Forum is ded though, why I keep posting this? LUL)
     
  4. VergilUa

    VergilUa

    Joined:
    Dec 22, 2014
    Posts:
    279
    Seems like this thread is going to be my blog. Since I've started progress posting, why not continue?

    I haven't found any solution, so I've decided to hack my own one.

    Small progress update:
    I've ended up writing additional ScriptableObject to store curve data, and AnimationClip itself.
    Also managed to salvage up code from AnimationClipEditor and attach it to my own SO's editor.
    Prettified it a bit, overall looking good.

    ScriptableObject's Editor:
    upload_2018-4-18_15-15-28.png

    Only thing left is to write an extension component for an Animator which feeds it actual curve parameters.
    Another bottleneck - additional curves handled on the native side of the Animator, which makes a trivial task into a bit of hacking again. This also means - no API for actually setting curves for native side. This would've been a blessing, since it would've also handled curve blending and increased performance (by decreasing operations done by additional component).

    Also, there's no way to extend actual Animator class, since it's sealed. So Animator.IsParameterControlledByCurve cannot be overriden (which is a shame, but not really a big loss).

    Another thing is that these custom curves have to be blended manually, which is maybe a problem too.

    I'll post conclusion later about Pro's and Con's of this solution (which is taken me more time than I expected from the trivial task).
     
    Last edited: Apr 18, 2018 at 1:45 PM