<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                本文章由cartzhang編寫,轉載請注明出處。 所有權利保留。? 文章鏈接:http://blog.csdn.net/cartzhang/article/details/48678217 作者:cartzhang 本文內容關于Unity導入帶動畫模型的動畫切分 ### 手動處理動畫分割 在導入FBX模型過程中,若帶有動畫呢,需要對它進行切分。 當然這個工作可以在Unity中完成。 比如: 這樣手動來分割進行。 ![](https://box.kancloud.cn/2016-03-09_56dfda857390b.jpg) ### 自動動畫切分 這就需要代碼了。 把代碼保存成cs文件,然后放在Editor文件夾中。若沒有此文件夾,就自己創建一個! 代碼如下: ~~~ // FbxAnimListPostprocessor.cs : Use an external text file to import a list of // splitted animations for FBX 3D models. // // Put this script in your "Assets/Editor" directory. When Importing or // Reimporting a FBX file, the script will search a text file with the // same name and the ".txt" extension. // File format: one line per animation clip "firstFrame-lastFrame loopFlag animationName" // The keyworks "loop" or "noloop" are optional. // Example: // 0-50 loop Move forward // 100-190 die using UnityEngine; using UnityEditor; using System.Collections; using System.IO; using System.Text.RegularExpressions; using System; using System.IO; public class FbxAnimListPostprocessor : AssetPostprocessor { public void OnPreprocessModel() { if (Path.GetExtension(assetPath).ToLower() == ".fbx" && !assetPath.Contains("@")) { try { string fileAnim; if (DragAndDrop.paths.Length <= 0) { return; } fileAnim = DragAndDrop.paths[0]; string ClipText = Path.ChangeExtension(fileAnim, ".txt"); StreamReader file = new StreamReader(ClipText); string sAnimList = file.ReadToEnd(); file.Close(); // if (EditorUtility.DisplayDialog("FBX Animation Import from file", fileAnim, "Import", "Cancel")) { System.Collections.ArrayList List = new ArrayList(); ParseAnimFile(sAnimList, ref List); ModelImporter modelImporter = assetImporter as ModelImporter; //modelImporter.clipAnimations. = true; modelImporter.clipAnimations = (ModelImporterClipAnimation[]) List.ToArray(typeof(ModelImporterClipAnimation)); EditorUtility.DisplayDialog("Imported animations", "Number of imported clips: " + modelImporter.clipAnimations.GetLength(0).ToString(), "OK"); } } catch { } // (Exception e) { EditorUtility.DisplayDialog("Imported animations", e.Message, "OK"); } } } void ParseAnimFile(string sAnimList, ref System.Collections.ArrayList List) { Regex regexString = new Regex(" *(?<firstFrame>[0-9]+) *- *(?<lastFrame>[0-9]+) *(?<loop>(loop|noloop| )) *(?<name>[^\r^\n]*[^\r^\n^ ])", RegexOptions.Compiled | RegexOptions.ExplicitCapture); Match match = regexString.Match(sAnimList, 0); while (match.Success) { ModelImporterClipAnimation clip = new ModelImporterClipAnimation(); if (match.Groups["firstFrame"].Success) { clip.firstFrame = System.Convert.ToInt32(match.Groups["firstFrame"].Value, 10); } if (match.Groups["lastFrame"].Success) { clip.lastFrame = System.Convert.ToInt32(match.Groups["lastFrame"].Value, 10); } if (match.Groups["loop"].Success) { clip.loop = match.Groups["loop"].Value == "loop"; } if (match.Groups["name"].Success) { clip.name = match.Groups["name"].Value; } List.Add(clip); match = regexString.Match(sAnimList, match.Index + match.Length); } } } ~~~ 怎么使用呢? 在你的FBX同目錄文件夾下,創建一個txt文件,名字與FBX文件同名即可。 ![](https://box.kancloud.cn/2016-03-09_56dfda85871d0.jpg) txt內容,為每個動畫的起始幀和結束幀,是否循環播放,和幀名。 CowGirl_Ani.txt ~~~ 0-50 loop Move forward 100-190 die ~~~ 把FBX文件拖入到Unity的資源中,可以看到彈出對話框。選擇Import導入,就會自動彈出分割動畫的數量。 若點擊cancle ,就會直接導入動畫,而不會分割動畫。 引用網址:http://wiki.unity3d.com/index.php/FbxAnimListPostprocessor thx! ----------------------- 若有問題,請隨時聯系! 非常感謝各位瀏覽!
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看