进口fbx角色动画read-only解

进口fbx角色动画read-only解

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

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

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

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

….

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117386.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • tcp/ip协议包含哪几层_ip协议提供的是一种什么服务

    tcp/ip协议包含哪几层_ip协议提供的是一种什么服务在OSI模型中ARP协议属于链路层;而在TCP/IP模型中,ARP协议属于网络层。1)ARP分层的位置是TCP/IP的网络层2)ARP报文是由以太网帧进行封装传输的。没有封装进IP包。3)实际上

    2022年8月5日
    6
  • ps修图教程新手入门:如何用Photoshop处理证件照「建议收藏」

    ps修图教程新手入门:如何用Photoshop处理证件照「建议收藏」今天小编给大家讲解如何用Photoshop处理证件照,证件照是大家生活中经常要用到的,相信很多同学碰到过需要给背景照换颜色的时候,却不知道如何更换背景颜色。我们平时照的证件照,一般都是红底,这时我们遇到要蓝底的时候怎么办呢?下面讲解ps修图教程新手入门如何用Photoshop处理证件照。下面,以一寸照片为例,讲解如何用Photoshop制作证件照。1、电脑操作2、ps软件:AdobePhotoshop2017(演示)一、ps改变尺寸1、打开证件照原件(图片小编从网上下载了一张,并打码

    2022年6月26日
    49
  • PAT乙级_1007

    PAT乙级_1007问题描述:让我们定义dn为:dn=pn+1-pn,其中pi是第i个素数。显然有d1=1且对于n&gt;1有dn是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。现给定任意正整数N(&lt;105),请计算不超过N的满足猜想的素数对的个数。输入格式:每个测试输入包含1个测试用例,给出正整数N。输出格式:每个测试用例的输出占一行,不超过N的满足猜想的素数对的个数…

    2022年6月11日
    21
  • google搜索引擎怎么用_如何使用谷歌搜索

    google搜索引擎怎么用_如何使用谷歌搜索2021年2月23日,在使用python的matplotlib模块画图的过程中,marker的点过于密集了,在国内的搜索引擎(你懂的)搜索了好长时间,也不知道是我的搜索关键字设置的不对,还是它就是这么垃圾,一直搜索不出来我需要的答案。无奈之下,只好试试google。在google里面使用中文搜索也是搜索不到答案,我使用英文关键字搜索,第一条搜索出来的便是StackOverflow的答案,立马解决了我的问题。这令我感触颇深,google搜索引擎确实是程序员的利器。所以一定必须用好google搜索。

    2025年10月24日
    4
  • 2021好玩的微信小程序_如何制作微信小程序

    2021好玩的微信小程序_如何制作微信小程序一、前期准备工作1、注册微信小程序开发者账号在官网注册页选择小程序注册即可,账号分为个人版和企业版:个人版相对于企业版注册流程更为简单和宽松。企业版注册需要支付认证费用,一般为300元,个人版不需要,企业版经过微信官方认证,更具有信誉度。个人版更多只是一个展示的平台,企业版可以作为一个完整的平台,个人版不可以做商业性质的小程序,但是企业版可以,个人版不可以开通微信支付。附近的小程序不显示个人版,只能通过搜索,扫码方式找到。个人版不支持快速获取微信用户的手机号。2、下载微信开发者工具微信平

    2022年9月30日
    1
  • Spring AOP理解与研发使用

    Spring AOP理解与研发使用SpringAOP理解与研发使用:基本理论(基本术语总结+具体开发注意事项+切点正则和指示器规则)+AOP开发应用与分析

    2022年7月12日
    18

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号