(BACKWARDS) Create anomalous default clip:

- Ensure backwards compatibility by creating an anomalous clip to be used by default on animators
This commit is contained in:
Haï~
2023-09-03 14:59:30 +02:00
parent 9cbdd51964
commit fbda5a01fa
+20 -1
View File
@@ -314,6 +314,25 @@ namespace AnimatorAsCode.V0
.WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(numberOf, 0f))); .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() public void RemoveAllMainLayers()
{ {
var layerName = _configuration.SystemName; var layerName = _configuration.SystemName;
@@ -379,7 +398,7 @@ namespace AnimatorAsCode.V0
private AacFlClip CreateEmptyClip() private AacFlClip CreateEmptyClip()
{ {
var emptyClip = DummyClipLasting(1, AacFlUnit.Frames); var emptyClip = AnomalousSingleKeyframeClip();
return emptyClip; return emptyClip;
} }