【转】Unity3d:读取FBX中的动画
【轉(zhuǎn)】Unity3d:讀取FBX中的動畫
從模型中獲得切割好的動畫clip,并且對其中設(shè)置好的動畫事件進(jìn)行修改方法:
1.動畫模型后綴為.FBX.在Unity3d中,能夠顯示FBX中的動畫。要加載模型中的AnimationClip,只要AssetDatabase.LoadAssetsAtPath(fbxPath,typeof(AnimationClip))就可以了。
這樣就加載出了FBX中的動畫。
void AnimLoad(string fbxPath)
? ? {
? ? ? ? AnimationClip clip = AssetDatabase.LoadAssetAtPath(fbxPath, typeof(AnimationClip)) as AnimationClip;
? ? }
2.想要加載FBX中切割好的多個AnimationClip。既然知道FBX中包含的類型我們都可以加載到,那么就全部加載出來,在遍歷得到我們想要的類型:
void AnimLoad(string fbxPath)
? ? {
? ? ? ? Object[] objs = AssetDatabase.LoadAllAssetsAtPath(fbxPath);
? ? ? ? foreach (Object o in objs)
? ? ? ? {
? ? ? ? ? ? if (o is AnimationClip)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Debug.Log(o.name + "is clip");
? ? ? ? ? ? }
? ? ? ? }
? ? }
3.我想要操作animationClip中的其他信息,可以用AnimationUtility
void AnimOperation(AnimationClip clip)
? ? {
? ? ? ? AnimationEvent[] evs = AnimationUtility.GetAnimationEvents(clip);
? ? ? ? foreach (AnimationEvent e in evs)
? ? ? ? {
? ? ? ? ? ? Debug.Log("do something");
? ? ? ? }
? ? }
posted on 2018-01-18 15:57 時空觀察者9號 閱讀(...) 評論(...) 編輯 收藏
總結(jié)
以上是生活随笔為你收集整理的【转】Unity3d:读取FBX中的动画的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#与U3D中字符串尾0
- 下一篇: 不可能的工作:在FBX模型导入脚本中生成