Search Unity

Deleting animation curve

Discussion in 'Scripting' started by MetosFate, May 28, 2010.

  1. MetosFate

    MetosFate

    Joined:
    May 28, 2010
    Posts:
    7
    I need to delete animation curve with transform.position from my animation clip.
    I duplicated animation. I can delete it using animation editor, but i need to delete a lot of animations, so i need a script. I have this one, but it doesn't work(((
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using System;
    5.  
    6. public class FixAnimation : ScriptableObject
    7. {
    8.     [MenuItem("Custom/FixAnimation")]
    9.     static void ListChildTransforms()
    10.     {
    11.         GameObject go = Selection.activeGameObject;
    12.         string parent_name = go.name;
    13.         AnimationClip anim=go.animation["jumpc"].clip;
    14.         //Hip
    15.         anim.SetCurve("Player/Armature/Master/Ass/Hip", typeof(Transform), "m_localPosition.x", null);
    16.         anim.SetCurve("Player/Armature/Master/Ass/Hip", typeof(Transform), "m_localPosition.y", null);
    17.         anim.SetCurve("Player/Armature/Master/Ass/Hip", typeof(Transform), "m_localPosition.z", null);
    18.      }
    19. }
    20.  
    It can be compiled, but it doesnt delete animation curves.
    Help me, please!!!!!! :( [/code]
     
  2. MetosFate

    MetosFate

    Joined:
    May 28, 2010
    Posts:
    7
    Up, help me please!
     
  3. MetosFate

    MetosFate

    Joined:
    May 28, 2010
    Posts:
    7
  4. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Try to set keys to null.
     
  5. MetosFate

    MetosFate

    Joined:
    May 28, 2010
    Posts:
    7
    Thanks, i will try to handle this, using keys.
     
  6. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
  7. MetosFate

    MetosFate

    Joined:
    May 28, 2010
    Posts:
    7
    Thanks for reply, but after trying everything you said, I still have a problems, curve is still there.




    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using System;
    5.  
    6. public class FixAnimation : ScriptableObject
    7. {
    8.     [MenuItem("Custom/FixAnimation")]
    9.     static void ListChildTransforms()
    10.     {
    11.  
    12.  
    13.     GameObject go = Selection.activeGameObject;
    14.  
    15.     string parent_name = go.name;
    16.  
    17.     AnimationClip anim=go.animation["name of clip"].clip;
    18.  
    19.    anim.SetCurve("path", typeof(Transform), "localPosition.x", null);
    20.  
    21.  
    22.  
    23.  }
    24.  
    25. }
    26.  
    And I have Debug message:
    "Cleaning up leaked objects in scene since no game object, component or manager is referencing them
    AnimationClip has been leaked 6 times.
    "
    But I dont understand what actually does it mean.
     
  8. MetosFate

    MetosFate

    Joined:
    May 28, 2010
    Posts:
    7
    Can't remove individual position animation curve localPosition.x you must remove the entire animation curve with m_LocalPosition.
     
  9. MetosFate

    MetosFate

    Joined:
    May 28, 2010
    Posts:
    7
    Thanks everybody for help. I've done with it. It was a bug, after copying project to another folder and reopening, everything begin work well.