Search Unity

  1. Unity 2018.3 is now released.
    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. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    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:
    85
    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:
    109
  3. JohnHudeski

    JohnHudeski

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