Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    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. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Custom Animation properties, Curves

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

  1. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    84
    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:
    82
  3. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    84
    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:
    23
    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.