Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed 3D Vector and 1D Axis binding dropdown usage in Input Actions Editor throwing NotImplementedExceptions.
- Fixed several missing tooltips from the Action/Binding Properties pane in Input Actions Editor.
- Fixed an issue in the InputActionAsset Editor where ControlType wasn't updated when ActionType changed.
- Fixed an issue in the InputActionAsset Editor where Canceling ControlScheme changes didn't reset the values in the UI.

## [1.8.0-pre.2] - 2023-11-09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ public static Command SelectControlScheme(int controlSchemeIndex)
};
}

public static Command ResetSelectedControlScheme()
{
return (in InputActionsEditorState state) =>
{
var controlSchemeSerializedProperty = state.serializedObject
.FindProperty(nameof(InputActionAsset.m_ControlSchemes))
.GetArrayElementAtIndex(state.selectedControlSchemeIndex);

if (controlSchemeSerializedProperty == null)
{
return state.With(
selectedControlSchemeIndex: -1,
selectedControlScheme: new InputControlScheme());
}

return state.With(
selectedControlScheme: new InputControlScheme(controlSchemeSerializedProperty));
};
}

public static Command SelectDeviceRequirement(int deviceRequirementIndex)
{
return (in InputActionsEditorState state) => state.With(selectedDeviceRequirementIndex: deviceRequirementIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ControlSchemesView(VisualElement root, StateContainer stateContainer, boo
InputActionsEditorConstants.ControlSchemeEditorViewUxml);

var controlSchemeVisualElement = controlSchemeEditor.CloneTree();
controlSchemeVisualElement.Q<Button>(kCancelButton).clicked += Close;
controlSchemeVisualElement.Q<Button>(kCancelButton).clicked += Cancel;
controlSchemeVisualElement.Q<Button>(kSaveButton).clicked += SaveAndClose;
controlSchemeVisualElement.Q<TextField>(kControlSchemeNameTextField).RegisterCallback<FocusOutEvent>(evt =>
{
Expand All @@ -50,7 +50,7 @@ public ControlSchemesView(VisualElement root, StateContainer stateContainer, boo
m_ModalWindow.Add(popupWindow);
root.Add(m_ModalWindow);
m_ModalWindow.StretchToParentSize();
m_ModalWindow.RegisterCallback<ClickEvent>(evt => Close());
m_ModalWindow.RegisterCallback<ClickEvent>(evt => CloseView());
popupWindow.RegisterCallback<ClickEvent>(evt => evt.StopPropagation());

m_ListView = controlSchemeVisualElement.Q<MultiColumnListView>(kControlSchemesListView);
Expand Down Expand Up @@ -111,12 +111,28 @@ public override void DestroyView()

private void SaveAndClose()
{
// Persist the current ControlScheme values to the SerializedProperty
Dispatch(ControlSchemeCommands.SaveControlScheme(m_NewName, m_UpdateExisting));
Close();
CloseView();
}

private void Close()
private void Cancel()
{
// Reload the selected ControlScheme values from the SerilaizedProperty and throw away any changes
Dispatch(ControlSchemeCommands.ResetSelectedControlScheme());
CloseView();
}

private void CloseView()
{
// Closing the View without explicitly selecting "Save" or "Cancel" holds the values in the
// current UI state but won't persist them; the Asset Editor state isn't dirtied.
//
// This means accidentally clicking outside of the View (closes the dialog) won't immediately
// cause loss of work: the "Edit Control Scheme" option can be selected to re-open the View
// the changes retained. However, if a different ControlScheme is selected or the Asset
// Editor window is closed, then the changes are lost.

m_NewName = "";
OnClosing?.Invoke(this);
}
Expand Down