Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Custom Animation properties, Curves

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

  1. JohnHudeski

    JohnHudeski

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

    Kybernetik

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

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    97
    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:
    33
    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:
    97
    This doesn't work if the clips are stored in a separate bone (not part of the humanoid skeleton)