zoukankan      html  css  js  c++  java
  • 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);          
    }
    }
    }
  • 相关阅读:
    Linux命令大全
    paramiko 使用总结(SSH 操作远端机器)
    Django之ModelForm详解
    django模板之forloop
    学习VUE笔记及遇到的坑
    bootstrap table加载失败
    使用RedisTemplate遇到的坑
    grunt 不是内部或外部命令,也不是可运行的程序或批处理文件
    SpringBoot关于系统之间的远程互相调用
    数据在网络中的传输
  • 原文地址:https://www.cnblogs.com/sifenkesi/p/2367797.html
Copyright © 2011-2022 走看看