• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Igor · May 29, 2010 at 06:09 PM · animationeditorcurveflagged-for-close

Deleting animation curve with editor script

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:

using UnityEngine; using UnityEditor; using System;

public class FixAnimation : ScriptableObject { [MenuItem("Custom/FixAnimation")] static void ListChildTransforms() {

     GameObject go = Selection.activeGameObject; 

     string parent_name = go.name; 

     AnimationClip anim=go.animation["jumpc"].clip; 

     //Hip 

     anim.SetCurve("Player/Armature/Master/Ass/Hip", typeof(Transform), "m_localPosition.x", null); 

     anim.SetCurve("Player/Armature/Master/Ass/Hip", typeof(Transform), "m_localPosition.y", null); 

     anim.SetCurve("Player/Armature/Master/Ass/Hip", typeof(Transform), "m_localPosition.z", null); 

  } 

}

It can be compiled, but it doesnt delete animation curves. Help me, please!!!!!!

Comment

People who like this

0 Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image · Sep 26, 2010 at 09:44 AM 0
Share

Flagging for close, as Igor's answer says it's fixed, and he hasn't been back since June.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by runevision · Jun 02, 2010 at 11:18 AM

First of all, you are using wrong property names.

Look at the documentation:
http://unity3d.com/support/documentation/ScriptReference/AnimationClip.SetCurve.html

It states that you can use localPosition.x, not m_localPosition.x. Note that m_LocalPosition.x is undocumented but should also work (no guarantee for future versions); however, notice the upper case L.

If you fix the property names themselves, and it still doesn't do anything, check that your path names are correct.

The path "Player/Armature/Master/Ass/Hip" will look for a child called "Player" and go down from there, so this should work if the Animation component is on the parent of "Player", but not if the Animation component is on the "Player" GameObject itself.

Comment

People who like this

0 Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Igor · Jun 02, 2010 at 01:09 PM 0
Share

Thanks for Reply, but i have already seen documentation, many times, I tried localPosition.x, m_localPosition.x, LocalPosition.x, m_LocalPosition.x, simple "localPosition" and "LocalPosition" I have already used "Armature/Master/Ass/Hip" path, "Master/Ass/Hip path", "/Armature/Master/Ass/Hip"

Nothing help me. So. Can you give an editor script, that works on your animation clip, that deletes your one curve. It must be not a big work, but can help me and other people, because it is useful for optimization of animation.

Here is a "prefab code", try it on your animation, please!!! And sorry for my persistence

using UnityEngine; using UnityEditor; using System;

public class FixAnimation : ScriptableObject { [MenuItem("Custom/FixAnimation")] static void ListChildTransforms() {

GameObject go = Selection.activeGameObject;

 string parent_name = go.name; 

 AnimationClip anim=go.animation["name of clip"].clip; 

anim.SetCurve("path", typeof(Transform), "localPosition.x", null);

}

}

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.

And this error without "m_" Can't remove individual position animation curve localPosition.x you must remove the entire animation curve with m_LocalPosition.

avatar image Igor · Jun 02, 2010 at 06:10 PM 0
Share

Thanks, Mr Rune, for help, you are clever and reliable, humanity needs more humans like you. I've done with it. It was a bug, after copying project to another folder and reopening, everything begin work well.

avatar image Paulius-Liekis Igor · Jun 07, 2010 at 08:20 AM 0
Share

Igor, could you mark Rune's answer as correct then, so other people know that this question is answered.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How can I define two-dimensional curves? (like: circle) 1 Answer

Animator Editor adding unwanted curves 0 Answers

Correcting missing component references in animation clips? 0 Answers

How to customize animation window 0 Answers

Parameterized Animation Clip 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges