From 4c4e4bc45d2dea677f72f739f66f05403457243c Mon Sep 17 00:00:00 2001 From: Simon Wittber Date: Thu, 23 Jan 2025 17:00:37 +0800 Subject: [PATCH 01/19] marked area of concern with comment --- .../InputSystem/Editor/ControlPicker/InputControlPathEditor.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index dbfc601023..cb747e70a3 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -179,6 +179,8 @@ private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Acti m_PickerDropdown.SetPickedCallback(path => { + //At this point, the serialized property can sometines be referencing the old input actions asset + Debug.Log(serializedProperty.serializedObject.targetObject.GetInstanceID()); serializedProperty.stringValue = path; m_PickerState.manualPathEditMode = false; modifiedCallback(); From 9f69adf349bd6c56c22be7211fab68b501c61e93 Mon Sep 17 00:00:00 2001 From: Simon Wittber Date: Thu, 23 Jan 2025 17:33:55 +0800 Subject: [PATCH 02/19] WIP --- .../AssetEditor/InputBindingPropertiesView.cs | 8 +++----- .../ControlPicker/InputControlPathEditor.cs | 20 +++++++++---------- .../InputControlPickerDropdown.cs | 1 + .../PropertyDrawers/InputControlPathDrawer.cs | 14 ++++++++++--- .../UITKAssetEditor/Views/ActionsTreeView.cs | 7 +++++++ .../Views/BindingPropertiesView.cs | 6 +++++- .../CompositePartBindingPropertiesView.cs | 6 +++++- 7 files changed, 41 insertions(+), 21 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs index 6e196023a4..c3138e684e 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs @@ -316,10 +316,7 @@ private void OnCompositeParametersModified() var nameAndParameters = NameAndParameters.Parse(path); nameAndParameters.parameters = m_CompositeParameters.GetParameters(); - m_PathProperty.stringValue = nameAndParameters.ToString(); - m_PathProperty.serializedObject.ApplyModifiedProperties(); - - OnPathChanged(); + OnPathChanged(nameAndParameters.ToString()); } private void OnBindingGroupsChanged() @@ -330,8 +327,9 @@ private void OnBindingGroupsChanged() onChange?.Invoke(k_GroupsChanged); } - private void OnPathChanged() + private void OnPathChanged(string path) { + m_PathProperty.stringValue = path; m_BindingProperty.serializedObject.ApplyModifiedProperties(); onChange?.Invoke(k_PathChanged); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs index cb747e70a3..7eac4480f4 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs @@ -26,7 +26,7 @@ public sealed class InputControlPathEditor : IDisposable /// Delegate that is called when the path has been modified. /// Optional label to display instead of display name of . /// is null. - public InputControlPathEditor(SerializedProperty pathProperty, InputControlPickerState pickerState, Action onModified, GUIContent label = null) + public InputControlPathEditor(SerializedProperty pathProperty, InputControlPickerState pickerState, Action onModified, GUIContent label = null) { if (pathProperty == null) throw new ArgumentNullException(nameof(pathProperty)); @@ -89,7 +89,7 @@ public void OnGUI() EditorGUILayout.EndHorizontal(); } - public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty property = null, Action modifiedCallback = null) + public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty property = null, Action modifiedCallback = null) { var pathLabel = label ?? m_PathLabel; var serializedProperty = property ?? pathProperty; @@ -141,7 +141,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert { serializedProperty.stringValue = path; serializedProperty.serializedObject.ApplyModifiedProperties(); - (modifiedCallback ?? onModified).Invoke(); + (modifiedCallback ?? onModified).Invoke(path); } } else @@ -151,7 +151,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert { SetExpectedControlLayoutFromAttribute(serializedProperty); ////TODO: for bindings that are part of composites, use the layout information from the [InputControl] attribute on the field - ShowDropdown(bindingTextRect, serializedProperty, modifiedCallback ?? onModified); + ShowDropdown(bindingTextRect, modifiedCallback ?? onModified); } } @@ -160,7 +160,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert EditorStyles.miniButton); } - private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Action modifiedCallback) + private void ShowDropdown(Rect rect, Action modifiedCallback) { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS InputActionsEditorSettingsProvider.SetIMGUIDropdownVisible(true, false); @@ -171,19 +171,16 @@ private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Acti m_PickerState, path => { - serializedProperty.stringValue = path; m_PickerState.manualPathEditMode = false; - modifiedCallback(); + modifiedCallback(path); }); } m_PickerDropdown.SetPickedCallback(path => { //At this point, the serialized property can sometines be referencing the old input actions asset - Debug.Log(serializedProperty.serializedObject.targetObject.GetInstanceID()); - serializedProperty.stringValue = path; m_PickerState.manualPathEditMode = false; - modifiedCallback(); + modifiedCallback(path); }); m_PickerDropdown.SetControlPathsToMatch(m_ControlPathsToMatch); @@ -204,7 +201,7 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property) } public SerializedProperty pathProperty { get; } - public Action onModified { get; } + public Action onModified { get; } private GUIContent m_PathLabel; private string m_ExpectedControlLayout; @@ -215,6 +212,7 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property) private InputControlPickerDropdown m_PickerDropdown; private readonly InputControlPickerState m_PickerState; private InputActionRebindingExtensions.RebindingOperation m_RebindingOperation; + } } #endif // UNITY_EDITOR diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs index 6609f622f5..c6d3c794e5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs @@ -127,6 +127,7 @@ protected override void ItemSelected(AdvancedDropdownItem item) InputActionsEditorSettingsProvider.SetIMGUIDropdownVisible(false, true); #endif var path = ((InputControlDropdownItem)item).controlPathWithDevice; + Debug.Log("Picked: " + path); m_OnPickCallback(path); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs index 54e921840d..65d27b97c3 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs @@ -39,12 +39,20 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten if (m_Editor == null) { m_Editor = new InputControlPathEditor(property, m_PickerState, - () => property.serializedObject.ApplyModifiedProperties(), + (path) => + { + property.stringValue = path; + property.serializedObject.ApplyModifiedProperties(); + }, label: label); } - + EditorGUI.BeginProperty(position, label, property); - m_Editor.OnGUI(position, label, property, () => property.serializedObject.ApplyModifiedProperties()); + m_Editor.OnGUI(position, label, property, (path) => + { + property.stringValue = path; + property.serializedObject.ApplyModifiedProperties(); + }); EditorGUI.EndProperty(); } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs index b85145747b..5be8919a97 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs @@ -32,6 +32,7 @@ internal class ActionsTreeView : ViewBase public ActionsTreeView(VisualElement root, StateContainer stateContainer) : base(root, stateContainer) { + Debug.Log("Rebuilding TreeView"); m_ActionMapsListView = root.Q("action-maps-list-view"); m_AddActionButton = root.Q