Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: NREs when doing ReadValue on OneModifierComposite. #1275

Merged
merged 3 commits into from Mar 3, 2021

Conversation

Rene-Damm
Copy link
Contributor

@Rene-Damm Rene-Damm commented Feb 24, 2021

Fixes https://forum.unity.com/threads/can-a-vector2-value-be-read-from-onemodifiercomposite.1012693/.

Bug

When introducing OneModifierComposite and TwoModifiersComposite, 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 a ReadValue<float>(myPart) or a ReadValue<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 a NullReferenceException from a typecheck.

Fix

Massage the typecheck to no longer require inheritance from InputBindingComposite<TValue> but instead ping InputBindingComposite.valueType for typechecks.

@Rene-Damm Rene-Damm merged commit 30500e7 into develop Mar 3, 2021
@Rene-Damm Rene-Damm deleted the fix-nre-with-onemodifiercomposite branch March 3, 2021 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants