/// <summary> /// 是否排除动作剪辑,不做减帧操作 /// </summary> static bool IsExcludeClip(CompressClip compress, string clip) { if (_defaultCompress != null && _defaultCompress.ExcludeBones.Contains(clip)) { return(true); } else if (compress != null && compress.ExcludeClips.Contains(clip)) { return(true); } return(false); }
/// <summary> /// 是否排除骨骼不做减帧操作 /// </summary> static bool IsExcludeBone(CompressClip compress, string bone) { if (bone.ToLower() == BIP001) { return(true); } else if (_defaultCompress != null && _defaultCompress.ExcludeBones.Contains(bone)) { return(true); } else if (compress != null && compress.ExcludeBones.Contains(bone)) { return(true); } return(false); }
/// <summary> /// 删除指定帧 /// </summary> /// <param name="clip">动画剪辑</param> /// <param name="keyName">帧名</param> static void CompressKey(CompressClip compress) { // 部分骨骼带位移 // 部分动画不做减帧压缩 // 动画压缩分类型:All,OnlyScale,None;All只包含Scale和Position for (int i = 0; i < _infos.Count; i++) { AnimationClip clip = _infos[i].clip; if (!IsExcludeClip(compress, clip.name)) { continue; } EditorCurveBinding[] curves = AnimationUtility.GetCurveBindings(clip); AnimationClip tempClip = Object.Instantiate(clip); clip.ClearCurves(); for (int j = 0; j < curves.Length; j++) { EditorCurveBinding curveBinding = curves[j]; int index = curveBinding.path.LastIndexOf("/"); string boneName = curveBinding.path.Substring(index + 1); if (!IsExcludeBone(compress, boneName)) { if (curveBinding.propertyName.Contains("Position") || curveBinding.propertyName.Contains("Scale")) { continue; } } AnimationCurve curve = AnimationUtility.GetEditorCurve(tempClip, curveBinding); clip.SetCurve(curveBinding.path, curveBinding.type, curveBinding.propertyName, curve); } } }
static void ClearCfg() { _infos.Clear(); _compresses.Clear(); _defaultCompress = null; }