-
Notifications
You must be signed in to change notification settings - Fork 332
Fix ISXB-1794: Processor (and interaction) list use composite part va… #2378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -311,9 +311,7 @@ | |
|
|
||
| public static IEnumerable<ParameterListView> GetInteractionsAsParameterListViews(InputActionsEditorState state, SerializedInputAction? inputAction) | ||
| { | ||
| Type expectedValueType = null; | ||
| if (inputAction.HasValue && !string.IsNullOrEmpty(inputAction.Value.expectedControlType)) | ||
| expectedValueType = EditorInputControlLayoutCache.GetValueType(inputAction.Value.expectedControlType); | ||
| var expectedValueType = GetExpectedValueTypeForProcessorsOrInteractions(state, inputAction); | ||
|
|
||
| var interactions = string.Empty; | ||
| if (inputAction.HasValue && state.selectionType == SelectionType.Action) | ||
|
|
@@ -328,13 +326,35 @@ | |
| InputInteraction.GetValueType); | ||
| } | ||
|
|
||
| public static IEnumerable<ParameterListView> GetProcessorsAsParameterListViews(InputActionsEditorState state, SerializedInputAction? inputAction) | ||
| /// <summary> | ||
| /// Expected value type for the current selection. When the selection is a composite part binding, | ||
| /// returns the part's value type (e.g. float) instead of the composite's (e.g. Vector2). ISXB-1794. | ||
| /// </summary> | ||
| private static Type GetExpectedValueTypeForProcessorsOrInteractions(InputActionsEditorState state, SerializedInputAction? inputAction) | ||
| { | ||
| var processors = string.Empty; | ||
| Type expectedValueType = null; | ||
| if (state.selectionType == SelectionType.Binding) | ||
| { | ||
| var binding = GetSelectedBinding(state); | ||
| if (binding.HasValue && binding.Value.isPartOfComposite) | ||
| { | ||
| var compositeName = NameAndParameters.Parse(binding.Value.compositePath).name; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Since To make the editor more robust, consider using the null-coalescing operator to ensure a safe fallback: var compositeName = NameAndParameters.Parse(binding.Value.compositePath ?? string.Empty).name;🤖 Helpful? 👍/👎
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, the UI could be exposed to any asset so adding robustness to it makes sense. @u-pr can you apply the suggested change to this PR? |
||
| var partName = binding.Value.name; | ||
| var expectedLayout = InputBindingComposite.GetExpectedControlLayoutName(compositeName, partName); | ||
| if (!string.IsNullOrEmpty(expectedLayout)) | ||
| return EditorInputControlLayoutCache.GetValueType(expectedLayout); | ||
| } | ||
| } | ||
|
Check warning on line 346 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/Selectors.cs
|
||
|
|
||
| if (inputAction.HasValue && !string.IsNullOrEmpty(inputAction.Value.expectedControlType)) | ||
| expectedValueType = EditorInputControlLayoutCache.GetValueType(inputAction.Value.expectedControlType); | ||
| return EditorInputControlLayoutCache.GetValueType(inputAction.Value.expectedControlType); | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| public static IEnumerable<ParameterListView> GetProcessorsAsParameterListViews(InputActionsEditorState state, SerializedInputAction? inputAction) | ||
| { | ||
| var processors = string.Empty; | ||
| var expectedValueType = GetExpectedValueTypeForProcessorsOrInteractions(state, inputAction); | ||
|
|
||
| if (inputAction.HasValue && state.selectionType == SelectionType.Action) | ||
| processors = inputAction.Value.processors; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name
GetExpectedValueTypeForProcessorsOrInteractionsis quite specific to its current callers. To improve maintainability, consider a more generic name likeGetExpectedValueTypeForSelection. This would better reflect the method's logic and make it more reusable if other parts of the editor need to resolve the expected value type in the future.🤖 Helpful? 👍/👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, this isn't the best function name, but it is at least not ambiguous.