Skip to content

Updated XRControllerInputRemapper. The changes made to XRControllerIn…#49

Open
thefirstfloor wants to merge 3 commits into
devfrom
48-unity-60004-imported-updated-input-package-in-which-the-xrcontrollerremapper-fails
Open

Updated XRControllerInputRemapper. The changes made to XRControllerIn…#49
thefirstfloor wants to merge 3 commits into
devfrom
48-unity-60004-imported-updated-input-package-in-which-the-xrcontrollerremapper-fails

Conversation

@thefirstfloor

Copy link
Copy Markdown
Member

It seems that unity updated some things in their input system.
Some changes were needed in the remapper script, also some validations are added to avoid exceptions and leftovers.

A.i claims:
…putRemapperNew.cs are fully compatible with versions of the Unity Input System package prior to 1.19.0 (including versions as old as 1.0.0).

…putRemapperNew.cs are fully compatible with versions of the Unity Input System package prior to 1.19.0 (including versions as old as 1.0.0).
@thefirstfloor thefirstfloor requested a review from eioe April 23, 2026 11:47
@thefirstfloor thefirstfloor added the fix Fixes a known issue. label Apr 23, 2026
@thefirstfloor

Copy link
Copy Markdown
Member Author

@eioe

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the XR controller input remapping MonoBehaviour to align with newer Unity Input System behavior by moving subscription management into the component lifecycle and adding guards to avoid null/index exceptions.

Changes:

  • Renamed the remapper MonoBehaviour type and adjusted component lifecycle methods to subscribe/unsubscribe in OnEnable/OnDisable.
  • Added validation to avoid FindIndex/null-reference exceptions when enabling/disabling remaps.
  • Introduced a runtime isSubscribed flag to prevent duplicate event subscriptions.
Comments suppressed due to low confidence (1)

Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs:69

  • Subscribe/Unsubscribe assumes methodToCall is non-null (r.methodToCall.Invoke). If ControllerInputRemap entries are ever created programmatically (not via Unity serialization), methodToCall will be null and this will throw at subscription time. Consider initializing methodToCall (e.g., to a new UnityEvent) and/or adding a null check before subscribing/unsubscribing.
		private void Subscribe(ControllerInputRemap r) {
			if (r.isSubscribed || r.inputActionSubmit == null || r.inputActionSubmit.action == null) return;
			
			r.inputActionSubmit.action.Enable();
			r.inputActionSubmit.action.performed += r.methodToCall.Invoke;
			r.isSubscribed = true;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs Outdated
Comment thread Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs Outdated
Adding a gate to check if component is active and enabled on subscribe call

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs Outdated
…putRemapperNew.cs are fully compatible with versions of the Unity Input System package prior to 1.19.0 (including versions as old as 1.0.0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fixes a known issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unity 6000.4 imported updated input package, in which the XRControllerRemapper fails

3 participants