From fbda5a01fa0693c08d3fcffb0e22548b29d21971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=C3=AF=7E?= Date: Mon, 19 Dec 2022 13:35:03 +0100 Subject: [PATCH] (BACKWARDS) Create anomalous default clip: - Ensure backwards compatibility by creating an anomalous clip to be used by default on animators --- Framework/Editor/V0/Aac.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Framework/Editor/V0/Aac.cs b/Framework/Editor/V0/Aac.cs index 8c6cb3d..6875034 100644 --- a/Framework/Editor/V0/Aac.cs +++ b/Framework/Editor/V0/Aac.cs @@ -314,6 +314,25 @@ namespace AnimatorAsCode.V0 .WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(numberOf, 0f))); } + // For backwards compatibility, generates an animation with 2 keyframes that are at a distance of 1 / 60 of 1 frame, + // that is 1 / 3600 seconds. + // This was due to DummyClipLasting returning a clip with unit conversion applied twice, + // resulting in an "undesired" animation which was functional anyways. + // Since this dummy clip is used internally on all uninitalized states, + // preserve this behaviour so that existing animators don't break due to this change. + protected AacFlClip AnomalousSingleKeyframeClip() + { + var numberOf = 1f; + var unit = AacFlUnit.Frames; + + var dummyClip = AacV0.NewClip(_configuration, $"D({numberOf} {Enum.GetName(typeof(AacFlUnit), unit)})"); + + var duration = unit == AacFlUnit.Frames ? numberOf / 60f : numberOf; + return new AacFlClip(_configuration, dummyClip) + .Animating(clip => clip.Animates("_ignored", typeof(GameObject), "m_IsActive") + .WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(duration, 0f))); + } + public void RemoveAllMainLayers() { var layerName = _configuration.SystemName; @@ -379,7 +398,7 @@ namespace AnimatorAsCode.V0 private AacFlClip CreateEmptyClip() { - var emptyClip = DummyClipLasting(1, AacFlUnit.Frames); + var emptyClip = AnomalousSingleKeyframeClip(); return emptyClip; }