日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Unity3D 自动切割动画

發布時間:2023/12/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Unity3D 自动切割动画 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

模型太復雜,動畫幀數多,手動切割動畫Unity要卡死三分鐘……搜索發現以下解決方法

原文地址點擊這里


using UnityEngine; using System.Collections; using UnityEditor;public class FBXAnimationsFix : AssetPostprocessor { public void OnPreprocessModel() { //當前正在導入的模型 ModelImporter modelImporter = (ModelImporter) assetImporter; AnimationClipConfig.init(); foreach (AnimationClipConfig.modelST item in AnimationClipConfig.modelList) { //當前導入模型的路徑包含我們modelST動作數據表中的模型名字,那就要對這個模型的動畫進行切割 if (assetPath.Contains(item.ModelName)) { modelImporter.animationType = ModelImporterAnimationType.Legacy; //modelImporter.splitAnimations = true; modelImporter.generateAnimations = ModelImporterGenerateAnimations.GenerateAnimations; ModelImporterClipAnimation[] animations = new ModelImporterClipAnimation[item.clipSTs.Length]; for (int i = 0; i < item.clipSTs.Length; i++) { animations[i] = SetClipAnimation(item.clipSTs[i].name, item.clipSTs[i].firstFrame, item.clipSTs[i].lastFrame, item.clipSTs[i].isloop); } modelImporter.clipAnimations = animations; } } }ModelImporterClipAnimation SetClipAnimation(string _name, int _first, int _last, bool _isLoop){ModelImporterClipAnimation tempClip = new ModelImporterClipAnimation();tempClip.name = _name;tempClip.firstFrame = _first;tempClip.lastFrame = _last;tempClip.loop = _isLoop;if (_isLoop)tempClip.wrapMode = WrapMode.Loop;elsetempClip.wrapMode = WrapMode.Default;return tempClip;} }

using UnityEngine; using System.Collections; using System.Collections.Generic;public static class AnimationClipConfig {public static bool isInit = false;public static List<modelST> modelList = new List<modelST>();public static void init(){if (isInit)return;isInit = true;modelST tempModel = new modelST();tempModel.ModelName = "name"; //模型名字 tempModel.clipSTs = new clipST[]{ new clipST("Step1" , 0, 20, false), new clipST("Step2" , 20, 40, false), new clipST("Step3" ,40, 70, false), new clipST("Step4" , 70, 90, false),};modelList.Add(tempModel);}#region STpublic class clipST{public string name;public int firstFrame;public int lastFrame;public bool isloop;public clipST(string _n, int _f, int _l, bool _i){name = _n;firstFrame = _f;lastFrame = _l;isloop = _i;}}public class modelST{public string ModelName;public clipST[] clipSTs;}#endregion }

總結

以上是生活随笔為你收集整理的Unity3D 自动切割动画的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。