Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Custom Animation properties, Curves

Discussion in 'Animation' started by JohnHudeski, Oct 5, 2018.

  1. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    86
    Is there any way to extract curves from custom properties
    It seems OnPostprocessGameObjectWithUserProperties only retrieves the very first value of a curve
     
  2. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    156
  3. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    86
    Thanks for the reply. It doesn't hold the solution.
    I just wrote a python reader that dumps the data to binary and a c# read that converts it to a unity curve. Can't believe I had to do that.
     
  4. teutonicus

    teutonicus

    Joined:
    Jul 4, 2012
    Posts:
    28
    in OnPostprocessModel:

    Code (CSharp):
    1. foreach (var clip in Object.FindObjectsOfType<AnimationClip>())
    2. {
    3.     Debug.Log("clip " + clip.name);
    4.     var curveBindings = UnityEditor.AnimationUtility.GetCurveBindings(clip);
    5.     foreach (var curveBinding in curveBindings)
    6.     {
    7.         var editorCurve = UnityEditor.AnimationUtility.GetEditorCurve(clip, curveBinding);
    8.         Debug.Log(editorCurve.length);
    9.         foreach (var key in editorCurve.keys)
    10.         {
    11.             Debug.Log("\t" + key.time + ",\t " + key.value);
    12.         }
    13.     }
    14. }
    This should give you all curves including custom properties and all of their keys. Code is rough and you'll need to filter out any editor preview clips from the model being imported when accessing them this way.
     
    JohnHudeski likes this.
  5. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    86
    This doesn't work if the clips are stored in a separate bone (not part of the humanoid skeleton)