日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

U3D中的又一个坑

發(fā)布時間:2025/3/18 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 U3D中的又一个坑 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

U3D中的又一個坑

1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEditor; 4 using UnityEngine; 5 6 public class animImport : AssetPostprocessor 7 { 8 9 //fbx動畫導(dǎo)入前的處理,對動畫集進(jìn)行切分,轉(zhuǎn)成單個的動畫子集 10 void OnPreprocessAnimation() 11 { 12 var modelImporter = assetImporter as ModelImporter; 13 var anims = new ModelImporterClipAnimation[10]; 14 for (var i = 0; i < anims.Length; ++i) 15 { 16 anims[i] = new ModelImporterClipAnimation(); 17 anims[i].takeName = "hello-" + i; 18 anims[i].name = "hello-" + i; 19 } 20 21 //錯誤寫法 22 //這里的clipAnimations是個屬性,對它賦值時會調(diào)用它的set方法,該方法會檢測數(shù)組的每個元素,有一個為NULL就報錯,示例如下: 23 modelImporter.clipAnimations = new ModelImporterClipAnimation[10]; //有10個元素的數(shù)組,每個都是NULL,運行時報錯 24 25 //正確寫法 26 //modelImporter.clipAnimations =操作一旦執(zhí)行,對clipAnimations中的任何元素的更改都不再起作用,必須在此操作前執(zhí)行更改 27 modelImporter.clipAnimations = anims; 28 for (var i = 0; i < modelImporter.clipAnimations.Length; ++i) 29 { 30 //anims[i].name更改了,但modelImporter.clipAnimations[i].name沒更改, 31 //雖然語法上它們?nèi)灾赶蛲蛔兞?#xff0c;應(yīng)該是內(nèi)部特殊處理 32 anims[i].name = "ani-" + i; 33 anims[i].takeName = "ani-" + i; 34 } 35 36 } 37 }

?

posted on 2018-01-16 14:58 時空觀察者9號 閱讀(...) 評論(...) 編輯 收藏

總結(jié)

以上是生活随笔為你收集整理的U3D中的又一个坑的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。