1. 程式人生 > >Unity中有兩種Animation Clip

Unity中有兩種Animation Clip

在Unity中,我們有兩種方法建立Animation Clip。

一種(後面簡稱方法一)是選中掛載了Animation元件的GameObject,在Animation視窗中點選Create New Clip創建出來的Animation Clip。


另一種(後面簡稱方法二)是在Project視窗的空白地方右鍵單擊,選擇Create->Animation創建出來的Animation Clip。


這兩種方法創建出來的都是.anim檔案,但是在使用上卻有點不一樣。

選中方法一建立的.anim檔案,Inspector視窗只有一個Wrap Mode選項。


而方法二建立的.anim檔案的Inspector卻比較複雜。


如果將Inspector切換為Debug模式,


可以看到方法一的.anim檔案的Animation Type是1,


而方法二的.anim檔案的Animation Type是2。


兩種.anim檔案都可以拖拽進GameObject身上掛載的Animation元件中,



也都可以在Animation視窗中編輯。



但是如果將方法二的.anim檔案拖拽進Animation元件,並作為元件的預設Clip的話,那麼遊戲執行的時候這個Clip其實是播不出來的,而且Console會報一條“The AnimationClip 'XXX' used by the Animation component 'XXX' must be marked as Legacy.”的警告資訊,以及一條“Default clip could not be found in attached animations list”的提示資訊。也就是說方法二的.anim檔案其實似乎不能直接用在Animation元件中。


但是方法二的.anim檔案卻可以拖拽進Animator視窗,作為Animator Controller的一個狀態(需要先建立一個Animator Controller),當GameObject身上掛載著Animator,並且Animator引用了這個Animator Controller的時候,這個動畫是可以正常播出的。


而方法一的.anim檔案卻無法拖拽進Animator的視窗。也就是說方法一的.anim檔案似乎不能用在Animator中。