• Animation动画


    注:Unity3D导入动画无法在动画视图中进行编辑,但如果你在Unity复制一个导入动画,复制的导入动画可以编辑。

    自认为U3D在这点上有点不方便,尤其是对于那些想要通过代码控制所有资源配置的开发团队。针对此问题,我写了一个批处理脚本用于自动复制出这些动画文件:

    using UnityEngine;
    using UnityEditor;
    using System.IO;
    using System.Collections;
    using System.Collections.Generic;

    public class AnimationBatch
    {
    [MenuItem("MyEditor/Animation Batch")]
    static void Execute()
    {
    foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
    {
    if (!(o is GameObject)) continue;
    if (!o.name.Contains("@")) continue;

    GameObject charFbx = (GameObject)o;

    string strClipName = charFbx.name;
    int nIndex = strClipName.LastIndexOf('@');
    strClipName = strClipName.Substring(nIndex + 1, strClipName.Length - nIndex - 1);

    AnimationClip newClip = new AnimationClip();
    EditorUtility.CopySerialized(charFbx.animation.GetClip(strClipName), newClip);

    string strNewClip = AssetDatabase.GetAssetPath(charFbx);
    strNewClip = strNewClip.Substring(0, strNewClip.LastIndexOf('/') + 1);
    strNewClip += strClipName;
    strNewClip += ".anim";

    if(!File.Exists(strNewClip))
    AssetDatabase.CreateAsset(newClip, strNewClip);
    }
    }

    }

    此脚本可以批处理的生成FBX动作文件中的AnimationClip,用于打关键帧。

    美术给的动作资源,很多时候都没有设置是否循环等属性,这时候我们程序也没必要每次都跑到美术旁边告诉他们进行更改,我们可以自己写一个批处理脚本,根据不同的动作统一修改其WrapMode,

    可参考如下脚本:

    using UnityEditor   ;
    using UnityEngine;
    using System.Collections;

    public class AnimationWrapSet
    {
    [MenuItem("MyEditor/Animation Wrap Set")]
    static void Execute()
    {
    foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
    {
    if (!(o is AnimationClip)) continue;

    AnimationClip clip = (AnimationClip)o;
    clip.wrapMode = WrapMode.Loop;
                EditorUtility.SetDirty(o);          
    }
    }
    }
  • 相关阅读:
    75. Sort Colors
    101. Symmetric Tree
    121. Best Time to Buy and Sell Stock
    136. Single Number
    104. Maximum Depth of Binary Tree
    70. Climbing Stairs
    64. Minimum Path Sum
    62. Unique Paths
    css知识点3
    css知识点2
  • 原文地址:https://www.cnblogs.com/sifenkesi/p/2367797.html
Copyright © 2020-2023  润新知