diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 655157b063..6425648904 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -31,6 +31,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed the TreeView compilation warnings when used with Unity 6.2 beta (ISX-2320) - Fixed actions being reset when disabling the InputSystemUIInputModule component [ISXB-1493](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1493) - Fixed a memory leak when disabling and enabling the InputSystemUIInputModule component at runtime [ISXB-1573](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1573) +- Fixed all InputControls being changed at once when you change just one by reverting `2a37caac288ac09bc9122234339dc5df8d3a0ca6`, which was an attempt at fixing [ISXB-1221] that introduced this regression [ISXB-1531] (https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1493) - Fixed PlayerInput component automatically switching away from the default ActionMap set to 'None'. - Fixed a console error being shown when targeting visionOS builds in 2022.3. - Fixed a Tap Interaction issue with analog controls. The Tap interaction would keep re-starting after timeout. [ISXB-627](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-627) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index 4ffc09886c..91d10fdc81 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -30,9 +30,8 @@ public InputControlPathEditor(SerializedProperty pathProperty, InputControlPicke { if (pathProperty == null) throw new ArgumentNullException(nameof(pathProperty)); - // Update the static pathProperty variable to the most recent serializedProperty. - // See comment on pathProperty for more information. - s_pathProperty = pathProperty; + + this.pathProperty = pathProperty; this.onModified = onModified; m_PickerState = pickerState ?? new InputControlPickerState(); m_PathLabel = label ?? new GUIContent(pathProperty.displayName, pathProperty.GetTooltip()); @@ -40,7 +39,6 @@ public InputControlPathEditor(SerializedProperty pathProperty, InputControlPicke public void Dispose() { - s_pathProperty = null; m_PickerDropdown?.Dispose(); } @@ -91,10 +89,10 @@ public void OnGUI() EditorGUILayout.EndHorizontal(); } - //TODO: on next major version remove property argument. public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty property = null, Action modifiedCallback = null) { var pathLabel = label ?? m_PathLabel; + var serializedProperty = property ?? pathProperty; var lineRect = rect; var labelRect = lineRect; @@ -115,7 +113,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert var path = String.Empty; try { - path = pathProperty.stringValue; + path = serializedProperty.stringValue; } catch { @@ -140,8 +138,8 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert path = EditorGUI.DelayedTextField(bindingTextRect, path); if (EditorGUI.EndChangeCheck()) { - pathProperty.stringValue = path; - pathProperty.serializedObject.ApplyModifiedProperties(); + serializedProperty.stringValue = path; + serializedProperty.serializedObject.ApplyModifiedProperties(); (modifiedCallback ?? onModified).Invoke(); } } @@ -150,9 +148,9 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert // Dropdown that shows binding text and allows opening control picker. if (EditorGUI.DropdownButton(bindingTextRect, new GUIContent(displayName), FocusType.Keyboard)) { - SetExpectedControlLayoutFromAttribute(pathProperty); + SetExpectedControlLayoutFromAttribute(serializedProperty); ////TODO: for bindings that are part of composites, use the layout information from the [InputControl] attribute on the field - ShowDropdown(bindingTextRect, modifiedCallback ?? onModified); + ShowDropdown(bindingTextRect, serializedProperty, modifiedCallback ?? onModified); } } @@ -161,7 +159,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert EditorStyles.miniButton); } - private void ShowDropdown(Rect rect, Action modifiedCallback) + private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Action modifiedCallback) { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS InputActionsEditorSettingsProvider.SetIMGUIDropdownVisible(true, false); @@ -172,13 +170,19 @@ private void ShowDropdown(Rect rect, Action modifiedCallback) m_PickerState, path => { - pathProperty.stringValue = path; - pathProperty.serializedObject.ApplyModifiedProperties(); + serializedProperty.stringValue = path; m_PickerState.manualPathEditMode = false; modifiedCallback(); }); } + m_PickerDropdown.SetPickedCallback(path => + { + serializedProperty.stringValue = path; + m_PickerState.manualPathEditMode = false; + modifiedCallback(); + }); + m_PickerDropdown.SetControlPathsToMatch(m_ControlPathsToMatch); m_PickerDropdown.SetExpectedControlLayout(m_ExpectedControlLayout); @@ -196,16 +200,7 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property) SetExpectedControlLayout(attribute.layout); } - // This static variable is a hack. Because the editor is rebuilt at unpredictable times with a new serializedObject, we need to keep updating - // this variable with most up to date serializedProperty, so that the picker dropdown can access the correct serializedProperty. - // The picker dropdown is a separate window and does not have access to the changed serializedObject reference. - // This could be removed if the InputControlPathEditor is converted to UITK with a stable, persistent serializedObject backing this editor. - // This property will be shared among multiple asset editor windows. - private static SerializedProperty s_pathProperty { get; set; } - - // This property will always return the most recent serializedProperty. - public SerializedProperty pathProperty { get => s_pathProperty;} - + public SerializedProperty pathProperty { get; } public Action onModified { get; } private GUIContent m_PathLabel; diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs index f3887c7e4b..6609f622f5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs @@ -58,6 +58,11 @@ public void SetExpectedControlLayout(string expectedControlLayout) Reload(); } + public void SetPickedCallback(Action action) + { + m_OnPickCallback = action; + } + protected override void OnDestroy() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs index 1176f527d8..54e921840d 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs @@ -44,7 +44,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } EditorGUI.BeginProperty(position, label, property); - m_Editor.OnGUI(position, label, property: null, modifiedCallback: () => property.serializedObject.ApplyModifiedProperties()); + m_Editor.OnGUI(position, label, property, () => property.serializedObject.ApplyModifiedProperties()); EditorGUI.EndProperty(); } }