Fix Animation.FillMode when cue isn't 0% or 100% #13775
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
This PR fixes
Animation.FillMode
for anyKeyFrame.Cue
.Additionally, it makes sure that the key frames insertion order doesn't matter.
What is the current behavior?
FillMode.Forward
doesn't work if there's no frame with a 100% cue.FillMode.Backward
doesn't work if there's no frame with a 0% cue.An animation can fail if the key frames order doesn't match the cues order.
What is the updated/expected behavior with this PR?
FillMode
works with any cue.How was the solution implemented (if it's not obvious)?
Currently, the
Animator
has a concept of neutral key frames, which are added at cues 0% and 100% if they don't exist. They're used to fall back to the neutral (non-animated) value outside of the animation's bounds. This isn't compatible withFillMode
: the animation value should be used in this case instead of the neutral value.This PR removes the neutral key frames. Instead, two properties
FillBefore
andFillAfter
are added to the internalAnimatorKeyFrame
, set on the appropriate frames when the animator is created. The animator can use these new properties to know if it should use the animated value or the neutral value.There were already tests for
FillMode
, with problems:Check_FillMode_Start_Value
worked partly because anAnimation.Delay
was set, and because the animated value was 0, matching the neutral's frame defaults. After removing it, several test cases were failing. Test cases have been added with and without delay, and with a non-zero value.Check_FillMode_End_Value
didn't use the test case parameters at all. Using them resulted in failures.Fixed issues