Skip to content

Commit bb2b109

Browse files
authored
NEW: Only show matching binding-paths for selected control scheme (ISX-1549) (#1724)
* hide other not matching bindings if control scheme selected * fixed selected control scheme does not reset issue
1 parent 3258450 commit bb2b109

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static Command SelectControlScheme(int controlSchemeIndex)
8080
return (in InputActionsEditorState state) =>
8181
{
8282
if (controlSchemeIndex == -1)
83-
return state.With(selectedControlSchemeIndex: controlSchemeIndex);
83+
return state.With(selectedControlSchemeIndex: controlSchemeIndex, selectedControlScheme: new InputControlScheme());
8484

8585
var controlSchemeSerializedProperty = state.serializedObject
8686
.FindProperty(nameof(InputActionAsset.m_ControlSchemes))

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/BindingPropertiesView.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public BindingPropertiesView(VisualElement root, Foldout foldout, StateContainer
2323
(_, controlSchemes, s) => new ViewState
2424
{
2525
controlSchemes = controlSchemes,
26+
currentControlScheme = s.selectedControlScheme,
2627
selectedBinding = Selectors.GetSelectedBinding(s),
2728
selectedBindingIndex = s.selectedBindingIndex,
2829
selectedBindingPath = Selectors.GetSelectedBindingPath(s),
@@ -57,6 +58,7 @@ public override void RedrawUI(ViewState viewState)
5758
{
5859
var controlPathEditor = new InputControlPathEditor(viewState.selectedBindingPath, new InputControlPickerState(),
5960
() => { Dispatch(Commands.ApplyModifiedProperties()); });
61+
controlPathEditor.SetControlPathsToMatch(viewState.currentControlScheme.deviceRequirements.Select(x => x.controlPath));
6062

6163
var inputAction = viewState.selectedInputAction;
6264
controlPathEditor.SetExpectedControlLayout(inputAction?.expectedControlType ?? "");
@@ -100,6 +102,7 @@ internal class ViewState
100102
public int selectedBindingIndex;
101103
public SerializedInputBinding? selectedBinding;
102104
public ViewStateCollection<InputControlScheme> controlSchemes;
105+
public InputControlScheme currentControlScheme;
103106
public SerializedProperty selectedBindingPath;
104107
public SerializedInputAction? selectedInputAction;
105108
}

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CompositePartBindingPropertiesView.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public override void RedrawUI(ViewState viewState)
4040
var controlPathEditor = new InputControlPathEditor(viewState.selectedBindingPath, new InputControlPickerState(),
4141
() => { Dispatch(Commands.ApplyModifiedProperties()); });
4242

43+
controlPathEditor.SetControlPathsToMatch(viewState.currentControlScheme.deviceRequirements.Select(x => x.controlPath));
4344
controlPathEditor.SetExpectedControlLayout(viewState.expectedControlLayoutName);
4445

4546
m_PathEditorContainer.onGUIHandler = controlPathEditor.OnGUI;
@@ -59,6 +60,7 @@ internal class ViewState
5960
public SerializedProperty selectedBindingPath;
6061
public SerializedInputBinding selectedBinding;
6162
public IEnumerable<string> compositePartNames;
63+
public InputControlScheme currentControlScheme;
6264
public string expectedControlLayoutName;
6365
public string selectedCompositePartName;
6466
}
@@ -78,6 +80,7 @@ public static CompositePartBindingPropertiesView.ViewState GetCompositePartBindi
7880
selectedBinding = binding,
7981
selectedBindingPath = GetSelectedBindingPath(state),
8082
selectedCompositePartName = selectedCompositePartName,
83+
currentControlScheme = state.selectedControlScheme,
8184
compositePartNames = compositeParts.Select(ObjectNames.NicifyVariableName).ToList(),
8285
expectedControlLayoutName = InputBindingComposite.GetExpectedControlLayoutName(binding.compositePath, binding.name) ?? ""
8386
};

0 commit comments

Comments
 (0)