diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index aec1b1285..9a65ffa14 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -19,9 +19,15 @@ The format is based on [Keep a Changelog]. ### Fixed - Prefab blinks when we see editor of PrefabSafeSet of prefab asset `#645` +- Fixes in 1.5.9 `#654` ### Security +## [1.5.9] - 2023-10-29 +## [1.5.9-rc.1] - 2023-10-28 +### Fixed +- Animation clip length can be changed [`#647`](https://github.com/anatawa12/AvatarOptimizer/pull/647) + ## [1.6.0-beta.1] - 2023-10-25 ### Added - Public API for registering component information [`#623`](https://github.com/anatawa12/AvatarOptimizer/pull/623) @@ -952,7 +958,9 @@ This release is mistake. - Clear Endpoint Position [Unreleased]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.0-beta.1...HEAD -[1.6.0-beta.1]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.8...v1.6.0-beta.1 +[1.6.0-beta.1]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.9...v1.6.0-beta.1 +[1.5.9]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.9-rc.1...v1.5.9 +[1.5.9-rc.1]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.8...v1.5.9-rc.1 [1.5.8]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.8-rc.1...v1.5.8 [1.5.8-rc.1]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.7...v1.5.8-rc.1 [1.5.7]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.7-beta.1...v1.5.7 diff --git a/CHANGELOG.md b/CHANGELOG.md index ad134babe..2a9135977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ The format is based on [Keep a Changelog]. ### Security +## [1.5.9] - 2023-10-29 +### Fixed +- Animation clip length can be changed [`#647`](https://github.com/anatawa12/AvatarOptimizer/pull/647) + ## [1.5.8] - 2023-10-20 ### Fixed - warning about VRCTestMarker when Build & Test [`#628`](https://github.com/anatawa12/AvatarOptimizer/pull/628) @@ -629,7 +633,8 @@ The format is based on [Keep a Changelog]. - Merge Bone - Clear Endpoint Position -[Unreleased]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.8...HEAD +[Unreleased]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.9...HEAD +[1.5.9]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.8...v1.5.9 [1.5.8]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.7...v1.5.8 [1.5.7]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.6...v1.5.7 [1.5.6]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.5.5...v1.5.6 diff --git a/Editor/ObjectMapping/ObjectMappingContext.cs b/Editor/ObjectMapping/ObjectMappingContext.cs index 22dba13e1..065f90f3a 100644 --- a/Editor/ObjectMapping/ObjectMappingContext.cs +++ b/Editor/ObjectMapping/ObjectMappingContext.cs @@ -131,6 +131,15 @@ private Object CustomClone(Object o) var newClip = new AnimationClip(); newClip.name = "rebased " + clip.name; + // copy m_UseHighQualityCurve with SerializedObject since m_UseHighQualityCurve doesn't have public API + using (var serializedClip = new SerializedObject(clip)) + using (var serializedNewClip = new SerializedObject(newClip)) + { + serializedNewClip.FindProperty("m_UseHighQualityCurve") + .boolValue = serializedClip.FindProperty("m_UseHighQualityCurve").boolValue; + serializedNewClip.ApplyModifiedPropertiesWithoutUndo(); + } + foreach (var binding in AnimationUtility.GetCurveBindings(clip)) { var newBindings = _mapping.MapBinding(binding); @@ -169,6 +178,16 @@ private Object CustomClone(Object o) } } + // ReSharper disable once CompareOfFloatsByEqualityOperator + if (newClip.length != clip.length) + { + // if newClip has less properties than original clip (especially for no properties), + // length of newClip can be changed which is bad. + newClip.SetCurve( + "$AvatarOptimizerClipLengthDummy$", typeof(GameObject), "m_IsActive", + AnimationCurve.Constant(clip.length, clip.length, 1f)); + } + newClip.wrapMode = clip.wrapMode; newClip.legacy = clip.legacy; newClip.frameRate = clip.frameRate;