From 94e2b052082d9cd314f92ac927e08518a0e8d7c8 Mon Sep 17 00:00:00 2001 From: josepmariapujol-unity <59828124+josepmariapujol-unity@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:23:56 +0100 Subject: [PATCH 1/6] Implement caching for InputControlPath display name Cache the display name for InputControlPath to reduce GC churn. --- .../Editor/ControlPicker/InputControlPathEditor.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index cf964d13b8..af37673fbb 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -123,9 +123,15 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert return; } - ////TODO: this should be cached; generates needless GC churn - var displayName = InputControlPath.ToHumanReadableString(path); + // To cache per path value and only recompute when the string actually changes. + if (!string.Equals(path, m_CachedPath, StringComparison.Ordinal)) + { + m_CachedPath = path; + m_CachedDisplayName = InputControlPath.ToHumanReadableString(path); + } + var displayName = m_CachedDisplayName; + // Either show dropdown control that opens path picker or show path directly as // text, if manual path editing is toggled on. if (m_PickerState.manualPathEditMode) From c6938d0e356ba45e69245763e9f14edbe8b7afde Mon Sep 17 00:00:00 2001 From: josepmariapujol-unity <59828124+josepmariapujol-unity@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:34:45 +0100 Subject: [PATCH 2/6] Update CHANGELOG with recent fixes Fixed caching for InputControlPath display name. --- Packages/com.unity.inputsystem/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index fb7dbba1bb..9f7f6b94de 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -17,6 +17,7 @@ however, it has to be formatted properly to pass verification tests. ### Fixed +- Fixed caching for InputControlPath display name. - Fixed the `Auto-Save` toggle button with some extra pixels to align the text in the window better. - Align title font size with toolbar style in `Input Action` window. - Updated Action Properties headers to use colors consistent with GameObject component headers. From 0ff4130f33945e781fafde832b85c2fba3865c35 Mon Sep 17 00:00:00 2001 From: josepmariapujol-unity <59828124+josepmariapujol-unity@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:36:11 +0100 Subject: [PATCH 3/6] Update Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../InputSystem/Editor/ControlPicker/InputControlPathEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index af37673fbb..fb891532a1 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -123,7 +123,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert return; } - // To cache per path value and only recompute when the string actually changes. + // Cache the display name per path value and only recompute when the string actually changes. if (!string.Equals(path, m_CachedPath, StringComparison.Ordinal)) { m_CachedPath = path; From 07d0b67ed6c748018c4d7a9870aeb4da517ff265 Mon Sep 17 00:00:00 2001 From: josepmariapujol-unity <59828124+josepmariapujol-unity@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:38:10 +0100 Subject: [PATCH 4/6] Add cached path and display name fields --- .../InputSystem/Editor/ControlPicker/InputControlPathEditor.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index fb891532a1..d2a28ac780 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -215,6 +215,9 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property) private string m_ExpectedControlLayout; private string[] m_ControlPathsToMatch; + private string m_CachedPath; + private string m_CachedDisplayName; + private InputControlPickerDropdown m_PickerDropdown; private readonly InputControlPickerState m_PickerState; From 082eb408d8176bbf258f76f624edcf759085d74a Mon Sep 17 00:00:00 2001 From: josepmariapujol-unity <59828124+josepmariapujol-unity@users.noreply.github.com> Date: Thu, 5 Feb 2026 14:22:14 +0100 Subject: [PATCH 5/6] Refactor path handling in InputControlPathEditor for empty or null --- .../Editor/ControlPicker/InputControlPathEditor.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index d2a28ac780..1a79d7dde2 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -127,7 +127,15 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert if (!string.Equals(path, m_CachedPath, StringComparison.Ordinal)) { m_CachedPath = path; - m_CachedDisplayName = InputControlPath.ToHumanReadableString(path); + + if (string.IsNullOrEmpty(path)) + { + m_CachedDisplayName = string.Empty; + } + else + { + m_CachedDisplayName = InputControlPath.ToHumanReadableString(path); + } } var displayName = m_CachedDisplayName; From bf00b583cd940889b62a3cff18435496bfe8e8f4 Mon Sep 17 00:00:00 2001 From: JosepMariaPujol Date: Thu, 5 Feb 2026 15:35:36 +0100 Subject: [PATCH 6/6] Update InputControlPathEditor.cs --- .../Editor/ControlPicker/InputControlPathEditor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index 1a79d7dde2..f5f481b0ab 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -139,7 +139,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert } var displayName = m_CachedDisplayName; - + // Either show dropdown control that opens path picker or show path directly as // text, if manual path editing is toggled on. if (m_PickerState.manualPathEditMode) @@ -225,7 +225,7 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property) private string m_CachedPath; private string m_CachedDisplayName; - + private InputControlPickerDropdown m_PickerDropdown; private readonly InputControlPickerState m_PickerState;