之前在Asset store上面下载了一个模型,有动画,但是想在Animation窗口编辑动画,插入关键帧的时候,出现了一点问题,发现动画切片是可读的。
在网上查了一下解决方案,后来在这里找到了答案:
http://answers.unity3d.com/questions/187907/how-to-add-keyframes-on-imported-read-only-animati.html
大概解决办法如下:
You have to duplicate the animationclip-asset. Select the animation clip in your imported model and press ctrl+d. Now you should have a seperate AnimationClip file. This animation clip have to be added to an instance of your model. Just drag your model asset into the scene and replace the referenced AnimationClip in the animation array. After you added the AnimationClip to your model you can open the animation editor window and select your model in the hierarchy. Select the right animation on top (if there are multiple) and you can edit anything in this animation. All changes will be saved to the .anim file since that's the animation you're using now.
You can't replace the AnimationClip on the imported model itself but you can create a new prefab out of the instanciated model in your scene. This prefab will used the assigned AnimationClip.
I have created a special AssetPostProcessor which automatically extracts the .anim files and add them automatically to the model prefab since we have 90+ animations ;)
先在Project视图中选中fbx的动画文件,然后按ctrl+d,复制动画切片,然后把模型拖到Scene视图中,然后选中Scene视图中的模型,手动修改模型所引用到的各种动画切片到你复制的动画切片,之后就会发现是可编辑的了。
插入关键帧的回调有两个办法:
1、在Hierarchy窗口中选中模型,然后打开Animation窗口,选中一个动画切片,然后将动画时间调整到需要的位置,然后按后面那个带加号的按钮会出现一个对话框,让你选择插入的回调函数,我这里是事先在对象上挂了一个脚本,所以这里会列出来这个脚本里的所有函数,如图:
二、是模型载入之后,进行avatar匹配,之后在Project视图中选中模型文件,然后在Inspector视图中选中Animation选项,然后在下面的Clips片段中选中你想插入的动画,然后将下面预览的红线拉到你想插入动画的帧,然后点击那个带加号的按钮。之后会出现一个插入函数的对话框,填入一个函数名,之后就可以在这个对象上挂一个脚本,然后填写相应的函数名即可有关键帧回调,如图: