From 21a399a0e0e55412c7c401e12acf57cd845048de Mon Sep 17 00:00:00 2001 From: jur Date: Thu, 23 Apr 2026 13:43:22 +0200 Subject: [PATCH 1/3] Updated XRControllerInputRemapper. The changes made to XRControllerInputRemapperNew.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). --- .../Scripts/XR/XRControllerInputRemapper.cs | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs b/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs index 5cb79bf6..f5e60e63 100644 --- a/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs +++ b/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs @@ -8,7 +8,7 @@ namespace Edia.XR { /// In order to be flexible for each Xblock, the remapping of a controller key to a method is a separate script [System.Serializable] [AddComponentMenu("EDIA/XR Remap Controller Input")] - public class XRControllerInputRemapper : MonoBehaviour { + public class XRControllerInputRemapperNew : MonoBehaviour { // TODO Allow multiple input actions to one ID // TODO Input remapping should take systems 'allowed interaction' into considiration @@ -19,13 +19,23 @@ public class ControllerInputRemap { public bool isEnabled = false; public InputActionReference inputActionSubmit; public UnityEvent methodToCall; + + internal bool isSubscribed = false; } public List Redirectors = new List(); - private void Start() { + private void OnEnable() { + foreach (ControllerInputRemap r in Redirectors) { + if (r.isEnabled) { + Subscribe(r); + } + } + } + + private void OnDisable() { foreach (ControllerInputRemap r in Redirectors) { - EnableRemapping(r.id, r.isEnabled); + Unsubscribe(r); } } @@ -43,10 +53,28 @@ public List GetControllerRemappings () { /// active public void EnableRemapping (string id, bool onOff) { int index = Redirectors.FindIndex(x => x.id == id); + if (index < 0) return; + + Redirectors[index].isEnabled = onOff; - if (onOff) Redirectors[index].inputActionSubmit.action.performed += Redirectors[index].methodToCall.Invoke; - else Redirectors[index].inputActionSubmit.action.performed -= Redirectors[index].methodToCall.Invoke; + if (onOff) Subscribe(Redirectors[index]); + else Unsubscribe(Redirectors[index]); } + 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; + } + + private void Unsubscribe(ControllerInputRemap r) { + if (!r.isSubscribed || r.inputActionSubmit == null || r.inputActionSubmit.action == null) return; + + r.inputActionSubmit.action.performed -= r.methodToCall.Invoke; + // Note: We don't disable the action here as other components might be using the same InputActionReference + r.isSubscribed = false; + } } } \ No newline at end of file From d316af317f6f3cd85b2326b9d92a3a5d9063adbe Mon Sep 17 00:00:00 2001 From: Jeroen De mooij Date: Tue, 19 May 2026 20:53:35 +0200 Subject: [PATCH 2/3] Potential fix for pull request finding 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> --- .../Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs b/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs index f5e60e63..950a3bf4 100644 --- a/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs +++ b/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs @@ -56,7 +56,9 @@ public void EnableRemapping (string id, bool onOff) { if (index < 0) return; Redirectors[index].isEnabled = onOff; - + + if (!isActiveAndEnabled) return; + if (onOff) Subscribe(Redirectors[index]); else Unsubscribe(Redirectors[index]); } From 96893f13872487ed5cede472d0959e8d5c5ffae1 Mon Sep 17 00:00:00 2001 From: jur Date: Wed, 20 May 2026 11:39:51 +0200 Subject: [PATCH 3/3] Updated XRControllerInputRemapper. The changes made to XRControllerInputRemapperNew.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). --- .../Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs b/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs index 950a3bf4..c0eefa27 100644 --- a/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs +++ b/Assets/com.edia.core/Runtime/Base/Scripts/XR/XRControllerInputRemapper.cs @@ -8,7 +8,7 @@ namespace Edia.XR { /// In order to be flexible for each Xblock, the remapping of a controller key to a method is a separate script [System.Serializable] [AddComponentMenu("EDIA/XR Remap Controller Input")] - public class XRControllerInputRemapperNew : MonoBehaviour { + public class XRControllerInputRemapper : MonoBehaviour { // TODO Allow multiple input actions to one ID // TODO Input remapping should take systems 'allowed interaction' into considiration