fix: cursed interaction with Unity Timeline causes animation curves to be lost (#952)

Closes: #950
This commit is contained in:
bd_ 2024-08-05 21:13:41 -07:00 committed by GitHub
parent 0806c621c5
commit 2cd996db55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -196,7 +196,7 @@ namespace nadena.dev.modular_avatar.animation
} }
} }
private string MapPath(UnityEditor.EditorCurveBinding binding) private string MapPath(EditorCurveBinding binding)
{ {
if (binding.type == typeof(Animator) && binding.path == "") if (binding.type == typeof(Animator) && binding.path == "")
{ {
@ -249,7 +249,10 @@ namespace nadena.dev.modular_avatar.animation
{ {
var newBinding = binding; var newBinding = binding;
newBinding.path = MapPath(binding); newBinding.path = MapPath(binding);
newClip.SetCurve(newBinding.path, newBinding.type, newBinding.propertyName, // https://github.com/bdunderscore/modular-avatar/issues/950
// It's reported that sometimes using SetObjectReferenceCurve right after SetCurve might cause the
// curves to be forgotten; use SetEditorCurve instead.
AnimationUtility.SetEditorCurve(newClip, newBinding,
AnimationUtility.GetEditorCurve(originalClip, binding)); AnimationUtility.GetEditorCurve(originalClip, binding));
} }