原文链接:http://answers.unity3d.com/questions/8172/how-to-add-new-curves-or-animation-events-to-an-im.html

unity4.3版本号

方法1:

You can use an editor script that copies over the curves from the original imported Animation Clip into the duplicated Animation Clip.

Here is such an editor script.

  • Place it in a folder called Editor, located somewhere inside the Assets folder.
  • The script assumes that you have already made a duplicate of the imported clip and called it the same name but with a *copy postfix. For example, if you have an imported clip called MyAnimation,
    it will search for *MyAnimation_copy*.
  • Select the original imported Animation Clip in the Project View.
  • You can now use the menu Assets -> Transfer Clip Curves to Copy

And the script:


  1. using UnityEditor;
  2. using UnityEngine;
  3. using System.Collections;
  4. public class CurvesTransferer {
  5. const string duplicatePostfix = "_copy";
  6. [MenuItem ("Assets/Transfer Clip Curves to Copy")]
  7. static void CopyCurvesToDuplicate () {
  8. // Get selected AnimationClip
  9. AnimationClip imported = Selection.activeObject as AnimationClip;
  10. if (imported == null) {
  11. Debug.Log("Selected object is not an AnimationClip");
  12. return;
  13. }
  14. // Find path of copy
  15. string importedPath = AssetDatabase.GetAssetPath(imported);
  16. string copyPath = importedPath.Substring(0, importedPath.LastIndexOf("/"));
  17. copyPath += "/" + imported.name + duplicatePostfix + ".anim";
  18. // Get copy AnimationClip
  19. AnimationClip copy = AssetDatabase.LoadAssetAtPath(copyPath, typeof(AnimationClip)) as AnimationClip;
  20. if (copy == null) {
  21. Debug.Log("No copy found at "+copyPath);
  22. return;
  23. }
  24. // Copy curves from imported to copy
  25. AnimationClipCurveData[] curveDatas = AnimationUtility.GetAllCurves(imported, true);
  26. for (int i=0; i<curveDatas.Length; i++) {
  27. AnimationUtility.SetEditorCurve(
  28. copy,
  29. curveDatas[i].path,
  30. curveDatas[i].type,
  31. curveDatas[i].propertyName,
  32. curveDatas[i].curve
  33. );
  34. }
  35. Debug.Log("Copying curves into "+copy.name+" is done");
  36. }
  37. }

方法2:

There is more simple variant. This script creates a new animation file itself and makes all copying operations.


  1. using UnityEditor;
  2. using UnityEngine;
  3. public class CurvesTransferer
  4. {
  5. const string duplicatePostfix = "_copy";
  6. static void CopyClip(string importedPath, string copyPath)
  7. {
  8. AnimationClip src = AssetDatabase.LoadAssetAtPath(importedPath, typeof(AnimationClip)) as AnimationClip;
  9. AnimationClip newClip = new AnimationClip();
  10. newClip.name = src.name + duplicatePostfix;
  11. AssetDatabase.CreateAsset(newClip, copyPath);
  12. AssetDatabase.Refresh();
  13. }
  14. [MenuItem("Assets/Transfer Clip Curves to Copy")]
  15. static void CopyCurvesToDuplicate()
  16. {
  17. // Get selected AnimationClip
  18. AnimationClip imported = Selection.activeObject as AnimationClip;
  19. if (imported == null)
  20. {
  21. Debug.Log("Selected object is not an AnimationClip");
  22. return;
  23. }
  24. // Find path of copy
  25. string importedPath = AssetDatabase.GetAssetPath(imported);
  26. string copyPath = importedPath.Substring(0, importedPath.LastIndexOf("/"));
  27. copyPath += "/" + imported.name + duplicatePostfix + ".anim";
  28. CopyClip(importedPath, copyPath);
  29. AnimationClip copy = AssetDatabase.LoadAssetAtPath(copyPath, typeof(AnimationClip)) as AnimationClip;
  30. if (copy == null)
  31. {
  32. Debug.Log("No copy found at " + copyPath);
  33. return;
  34. }
  35. // Copy curves from imported to copy
  36. AnimationClipCurveData[] curveDatas = AnimationUtility.GetAllCurves(imported, true);
  37. for (int i = 0; i < curveDatas.Length; i++)
  38. {
  39. AnimationUtility.SetEditorCurve(
  40. copy,
  41. curveDatas[i].path,
  42. curveDatas[i].type,
  43. curveDatas[i].propertyName,
  44. curveDatas[i].curve
  45. );
  46. }
  47. Debug.Log("Copying curves into " + copy.name + " is done");
  48. }
  49. }

方法3:

Guys, I loved this script so much, I went ahead and added a couple of features.

Here is a modified version of MaDDoX's edit that includes logic for automatically placing the animations into folders.

It first uses an animations folder to contain them all and then if the animation came from an FBX file, it will use the FBX's name to create a subfolder for those animations. Hopefully, this helps y'all keep things organized.



  1. using UnityEditor;
  2. using UnityEngine;
  3. using System.IO;
  4. using System.Collections;
  5. public class MultipleCurvesTransferer {
  6. const string duplicatePostfix = "Edit";
  7. const string animationFolder = "Animations";
  8. static void CopyClip(string importedPath, string copyPath) {
  9. AnimationClip src = AssetDatabase.LoadAssetAtPath(importedPath, typeof(AnimationClip)) as AnimationClip;
  10. AnimationClip newClip = new AnimationClip();
  11. newClip.name = src.name + duplicatePostfix;
  12. AssetDatabase.CreateAsset(newClip, copyPath);
  13. AssetDatabase.Refresh();
  14. }
  15. [MenuItem("Assets/Transfer Multiple Clips Curves to Copy")]
  16. static void CopyCurvesToDuplicate()
  17. {
  18. // Get selected AnimationClip
  19. Object[] imported = Selection.GetFiltered(typeof(AnimationClip), SelectionMode.Unfiltered);
  20. if (imported.Length == 0)
  21. {
  22. Debug.LogWarning("Either no objects were selected or the objects selected were not AnimationClips.");
  23. return;
  24. }
  25. //If necessary, create the animations folder.
  26. if (Directory.Exists("Assets/" + animationFolder) == false) {
  27. AssetDatabase.CreateFolder("Assets", animationFolder);
  28. }
  29. foreach (AnimationClip clip in imported) {
  30. string importedPath = AssetDatabase.GetAssetPath(clip);
  31. //If the animation came from an FBX, then use the FBX name as a subfolder to contain the animations.
  32. string copyPath;
  33. if (importedPath.Contains(".fbx")) {
  34. //With subfolder.
  35. string folder = importedPath.Substring(importedPath.LastIndexOf("/") + 1, importedPath.LastIndexOf(".") - importedPath.LastIndexOf("/") - 1);
  36. if (!Directory.Exists("Assets/Animations/" + folder)) {
  37. AssetDatabase.CreateFolder("Assets/Animations", folder);
  38. }
  39. copyPath = "Assets/Animations/" + folder + "/" + clip.name + duplicatePostfix + ".anim";
  40. } else {
  41. //No Subfolder
  42. copyPath = "Assets/Animations/" + clip.name + duplicatePostfix + ".anim";
  43. }
  44. Debug.Log("CopyPath: " + copyPath);
  45. CopyClip(importedPath, copyPath);
  46. AnimationClip copy = AssetDatabase.LoadAssetAtPath(copyPath, typeof(AnimationClip)) as AnimationClip;
  47. if (copy == null)
  48. {
  49. Debug.Log("No copy found at " + copyPath);
  50. return;
  51. }
  52. // Copy curves from imported to copy
  53. AnimationClipCurveData[] curveDatas = AnimationUtility.GetAllCurves(clip, true);
  54. for (int i = 0; i < curveDatas.Length; i++)
  55. {
  56. AnimationUtility.SetEditorCurve(
  57. copy,
  58. curveDatas[i].path,
  59. curveDatas[i].type,
  60. curveDatas[i].propertyName,
  61. curveDatas[i].curve
  62. );
  63. }
  64. Debug.Log("Copying curves into " + copy.name + " is done");
  65. }
  66. }
  67. }

....

进口fbx角色动画read-only解的更多相关文章

  1. CSS3图片翻转动画技术详解

    CSS动画非常的有趣:这种技术的美就在于,通过使用很多简单的属性,你能创建出漂亮的消隐效果.其中代表性的一种就是CSS图片翻转效果,能让你看到一张卡片的正反两面上的内容.本文就是要用最简单的方法向大家 ...

  2. iOS:核心动画的详解介绍:CAAnimation(抽象类)及其子类

    核心动画的详解介绍:CAAnimation(抽象类)   1.核心动画基本概念 Core Animation是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍! 使用它 ...

  3. Android Animations 视图动画使用详解!!!

    转自:http://www.open-open.com/lib/view/open1335777066015.html Android Animations 视图动画使用详解 一.动画类型 Andro ...

  4. pygame 笔记-3 角色动画及背景的使用

    上二节,已经知道如何控制基本的运动了,但是只有一个很单调的方块,不太美观,本节学习如何加载背景图,以及角色的动画. 素材准备:(原自github) 角色动画的原理:动画都是一帧帧渲染的,比如向左走的动 ...

  5. POPSpring动画参数详解

    POPSpring动画参数详解 效果 源码 https://github.com/YouXianMing/Animations // // POPSpringParameterController.m ...

  6. 【Salvation】——怪物角色动画&主角碰撞死亡动画

    写在前面:这个动画功能同样也是使用JavaScript编写脚本,在Unity3D游戏引擎的环境中实现,在怪物的角色动画中,很多与人物相同,这里不再重复. 一.设计敌人 拖一个精英sprite到层次面板 ...

  7. Unity3D NGUI UIPlayTween(原UIButtonTween)动画事件详解

    http://blog.csdn.net/asd237241291/article/details/8507817 原创文章如需转载请注明:转载自 脱莫柔Unity3D学习之旅 Unity3D引擎技术 ...

  8. Android基础夯实--重温动画(五)之属性动画 ObjectAnimator详解

    只有一种真正的英雄主义 一.摘要 ObjectAnimator是ValueAnimator的子类,它和ValueAnimator一样,同样具有计算属性值的功能,但对比ValueAnimator,它会更 ...

  9. RocketMQ——角色与术语详解

    原文地址:http://jaskey.github.io/blog/2016/12/15/rocketmq-concept/ RocketMQ——角色与术语详解 2016-12-15 THU 15:4 ...

随机推荐

  1. ecshop后台权限增加

    1.在后台“推荐管理”里添加“推荐人分成”.“会员分成”两个操作功能以及权限     index.php?act=menu     incluedes/inc_priv.php:权限对照表.inc_m ...

  2. SQLiteDatabase和Contentprovider

    SQLiteDatabase和Contentprovider这两个数据库,我一般是用前面一个,喜欢它的操作数据库的语句,简单明了,可惜有时遇到数据库同步的问题,有时我们需要在一个数据库下建立多个表,多 ...

  3. NYOJ 709(ZZULIOJ1481) 异 形 卵

    题目描写叙述 我们探索宇宙,是想了解浩瀚星空的奥妙,但我们却非常少意识到宇宙深处藏匿的危急,它们无时无刻不紧盯着我们的地球.假设外星人拜訪我们,结果可能与哥伦布当年踏足美洲大陆不会有什么两样,这是历史 ...

  4. TP-LINK telnet远程 重启路由器(转)

    突然断网,以前房东的路由器管理页面可以打开,今天突然间就打不开了.ping了下,可以ping通,于是就想起了房东的路由器是TP-LINK的 可以 telnet登陆的.每次,断网,我都会重启房东的路由器 ...

  5. java中处理字符编码(网页与数据库)(转)

    首先声明一下,此文章时从网上转载的.如下的某些方法是确实管用,但是从中发现了有一点不足,就是原文笔者没考虑使用不同Web Server时出现的情况,比如文章里我用红色字体画出来的部分代码在Tomcat ...

  6. ios发电子邮件

    ios发电子邮件 by 吴雪莹 第一: NSString *myEmail = @"3423423423@qq.com"; NSString *toemail = @"a ...

  7. 解决SMARTFORMS 中table 控件单行跨页的问题

    在CX项目中,MM模块做了大量的的单据打印的工作,一个问题困扰了我好久,一直不能解决.当物料描述很长时,table控件在单元格中能自动换行,这样就有可能在换页处出现一行记录的一部分打在上一页,一部分记 ...

  8. java程序开发代写(QQ:928900200)

    条件:手机1.2都是安卓智能机,手机1开热点,手机2链接手机1,功能:A手机2通过刷手机网页,登陆手机1设定的页面并下载其手机的指定文件,B手机1控制手机2的流量,当通过的流量多的时候,停止流量的供应

  9. 自己实现的Boost库中的lexical_cast随意类型转换

    知道了C++的I/O设施之后.这些就变的非常easy了. 假设你常常使用,时间长了就会有感觉.这个事情是多此一举吗?就当是练习吧,知道原理之后,你会认为用起来更舒畅,更喜欢C++了. #include ...

  10. 【转】Android Web Server

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://vaero.blog.51cto.com/4350852/1188602 Andr ...