Make sure your Unity Version >= 2021.3
- Open
Window
->Package Manager
- Click
+
->Add package from git URL...
- Enter
https://github.com/txtxj/Unity-Animation-Compression-Keyframe-Reducer.git?path=Assets/Plugins/Citrine/KeyframeReducer
Read the animation curve into several tracks, each track compressed independently.
将动画曲线读入多个轨道,每个轨道独立压缩。
First, all components of the same variable are combined and stored in the IKeyframeBase
implementation.
首先,每个变量的所有分量被组合存储在 IKeyframeBase
的一个实现(轨道)中。
Then, for each curve, determine whether each keyframe can be interpolated by the two keyframes before and after it, and if so, this frame can be deleted.
然后,对于每个曲线的每个关键帧,如果该帧可以通过其前后两个关键帧插值得到,则删除该帧。
The only interface is
唯一的接口如下
AnimationClip clip;
clip.ReduceKeyframes(rotationError, positionError, scaleError, checkData);
You can use the scripts under inside the Editor:
在编辑器下通过以下方法使用工具:
-
As Context Menu of file (
RMB
->Citrine
->Fast Keyframe Reduction
):右键快速压缩选中动画
-
As Menu Item for selected file (
Assets
->Citrine
->Fast Keyframe Reduction
):工具栏中快速压缩选中动画
-
As Window (
Tools
->Citrine
->Keyframe Reducer
)打开完整窗口
You can easily derive curve classes of other data types and compress them by implement IKeyframeBase<T>
and AnimationCurveBase<T>
, and then add an error function to KeyframeReducer.
通过派生 IKeyframeBase<T>
和 AnimationCurveBase<T>
,并添加一个误差函数,即可压缩其他数据类型的曲线。
Origin |
Reduced |
Model source: https://github.com/fish-ken/unity-animation-compressor
before | after | |
---|---|---|
Attack | 176.3 | 168.1 |
Dash | 97.7 | 87.9 |
Skill | 446.3 | 415.0 |
Walk | 78.1 | 74.8 |
Error Rate: 0.5%