Fixing BC OnEnable issue when non-default activation type specified in-editor #10039
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.
Overview
A regression was introduced in a previous
BoundsControl
fix that impacted activation behavior when a non-default activation type was specified in-editor. Behavior was correct when aBoundsControl
was set up at runtime, asOnEnable
would run with the default activation type, and any subsequentset
s toBoundsControlActivationType
would properly evaluate the activation policy. The regression only impacted scenarios when a non-default activation type was specified in-editor, andOnEnable
ran with that activation type.As a result, this is technically a symptom of missing test coverage. However, this bug is only visible when an option is specified in edit-mode, and then the scene is played. As we can't really write tests that cover a transition from edit to play mode, @CDiaz-MS confirmed that this should be alright to merge without a specific test. This issue can be smoked out by running the
BoundsControlExamples
example scene and checking that the BCs do not activate when they're not supposed to.Root cause: the order of
CreateRig
andSetActivationFlags
had been swapped in a previous fix, asSetActivationFlags
requires theTargetBounds
to be set in order to be able to determine the flattening result.CreateRig
was moved to be called beforeSetActivationFlags
, so thatDetermineTargetBounds
would be called beforeSetActivationFlags
needed theTargetBounds
. However, this introduced a regression whereinCreateRig
would not respect a non-default activation type if specified in-editor, as it was not calculated yet. The fix is to revert to the prior ordering ofCreateRig
andSetActivationFlags
, but introduce a preemptive call toDetermineTargetBounds
, to make sureTargetBounds
has been initialized before any other functions need it.Changes
CreateRig
andSetActivationFlags
to a prior versionDetermineTargetBounds
to resolve target bounds before any other functions need itVerification
As specified above, a test to cover this behavior is not practically implementable. Verification can be done by smoke testing the
BoundsControlExamples
scene.