FIX: NREs when doing ReadValue on OneModifierComposite. #1275
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.
Fixes https://forum.unity.com/threads/can-a-vector2-value-be-read-from-onemodifiercomposite.1012693/.
Bug
When introducing
OneModifierComposite
andTwoModifiersComposite
, the composite binding API was opened up to allow a composite to determine its value type at runtime rather than at compile-time. Previously, you had to determine ahead of time whether you wanted to do aReadValue<float>(myPart)
or aReadValue<Vector2>(myPart)
. Now, you can determine the actual value type at runtime based on what is actually bound to the part and you can read the value into a raw byte buffer.However, not all code paths were updated to reflect the change. Embarrassingly, the main code path leading through
InputAction.CallbackContext.ReadValue
was not updated properly and ended up throwing aNullReferenceException
from a typecheck.Fix
Massage the typecheck to no longer require inheritance from
InputBindingComposite<TValue>
but instead pingInputBindingComposite.valueType
for typechecks.