Skip to content

Commit ee06a07

Browse files
authored
Merge branch 'develop' into isxb-1343-show-dialog-for-unsaved-changes
2 parents 8d45778 + c1222db commit ee06a07

23 files changed

+319
-75
lines changed

Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ public override void OneTimeSetUp()
2121
{
2222
base.OneTimeSetUp();
2323
m_Asset = AssetDatabaseUtils.CreateAsset<InputActionAsset>();
24-
m_Asset.AddActionMap("First Name");
24+
var actionMap = m_Asset.AddActionMap("First Name");
2525
m_Asset.AddActionMap("Second Name");
2626
m_Asset.AddActionMap("Third Name");
27+
28+
actionMap.AddAction("Action One");
29+
actionMap.AddAction("Action Two");
2730
}
2831

2932
public override void OneTimeTearDown()
@@ -55,6 +58,19 @@ IEnumerator WaitForActionMapRename(int index, bool isActive, double timeoutSecs
5558
}, $"WaitForActionMapRename {index} {isActive}", timeoutSecs);
5659
}
5760

61+
IEnumerator WaitForActionRename(int index, bool isActive, double timeoutSecs = 5.0)
62+
{
63+
return WaitUntil(() =>
64+
{
65+
var actionItems = m_Window.rootVisualElement.Q("actions-container").Query<InputActionsTreeViewItem>().ToList();
66+
if (actionItems.Count > index && actionItems[index].IsFocused == isActive)
67+
{
68+
return true;
69+
}
70+
return false;
71+
}, $"WaitForActionRename {index} {isActive}", timeoutSecs);
72+
}
73+
5874
#endregion
5975

6076
[Test]
@@ -177,5 +193,53 @@ public IEnumerator CanDeleteActionMap()
177193
Assert.That(m_Window.currentAssetInEditor.actionMaps[0].name, Is.EqualTo("First Name"));
178194
Assert.That(m_Window.currentAssetInEditor.actionMaps[1].name, Is.EqualTo("Third Name"));
179195
}
196+
197+
[UnityTest]
198+
[Ignore("Instability, see ISXB-1284")]
199+
public IEnumerator CanRenameAction()
200+
{
201+
var actionContainer = m_Window.rootVisualElement.Q("actions-container");
202+
var actionItem = actionContainer.Query<InputActionsTreeViewItem>().ToList();
203+
Assume.That(actionItem[1].Q<Label>("name").text, Is.EqualTo("Action Two"));
204+
205+
m_Window.rootVisualElement.Q<TreeView>("actions-tree-view").Focus();
206+
m_Window.rootVisualElement.Q<TreeView>("actions-tree-view").selectedIndex = 1;
207+
208+
// Selection change triggers a state change, wait for the scheduler to process the frame
209+
yield return WaitForSchedulerLoop();
210+
yield return WaitForNotDirty();
211+
yield return WaitForFocus(m_Window.rootVisualElement.Q<TreeView>("actions-tree-view"));
212+
213+
// Re-fetch the actions since the UI may have refreshed.
214+
actionItem = actionContainer.Query<InputActionsTreeViewItem>().ToList();
215+
216+
// Click twice to start the rename
217+
SimulateClickOn(actionItem[1]);
218+
// If the item is already focused, don't click again
219+
if (!actionItem[1].IsFocused)
220+
{
221+
SimulateClickOn(actionItem[1]);
222+
}
223+
224+
yield return WaitForActionRename(1, isActive: true);
225+
226+
// Rename the action
227+
SimulateTypingText("New Name");
228+
229+
// Wait for rename to end and focus to return from text field
230+
yield return WaitForSchedulerLoop();
231+
yield return WaitForFocus(m_Window.rootVisualElement.Q<TreeView>("actions-tree-view"));
232+
233+
// Check on the UI side
234+
actionContainer = m_Window.rootVisualElement.Q("actions-container");
235+
Assume.That(actionContainer, Is.Not.Null);
236+
actionItem = actionContainer.Query<InputActionsTreeViewItem>().ToList();
237+
Assert.That(actionItem, Is.Not.Null);
238+
Assert.That(actionItem.Count, Is.EqualTo(2));
239+
Assert.That(actionItem[1].Q<Label>("name").text, Is.EqualTo("New Name"));
240+
241+
// Check on the asset side
242+
Assert.That(m_Window.currentAssetInEditor.actionMaps[0].actions[1].name, Is.EqualTo("New Name"));
243+
}
180244
}
181245
#endif

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,10 +2911,16 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29112911
Assert.That(scene.leftChildReceiver.events,
29122912
EventSequence(
29132913
OneEvent("type", EventType.Move),
2914+
OneEvent("device", gamepad),
29142915
OneEvent("moveDir", MoveDirection.Right),
29152916
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
29162917
Assert.That(scene.rightChildReceiver.events, Is.Empty);
29172918

2919+
#if UNITY_INPUT_SYSTEM_INPUT_MODULE_NAVIGATION_DEVICE_TYPE
2920+
Assert.That(scene.uiModule.GetNavigationEventDeviceType(scene.leftChildReceiver.events[0].data),
2921+
Is.EqualTo(NavigationDeviceType.NonKeyboard));
2922+
#endif
2923+
29182924
scene.leftChildReceiver.events.Clear();
29192925

29202926
// Move left.
@@ -2924,6 +2930,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29242930
Assert.That(scene.leftChildReceiver.events,
29252931
EventSequence(
29262932
OneEvent("type", EventType.Move),
2933+
OneEvent("device", gamepad),
29272934
OneEvent("moveDir", MoveDirection.Left),
29282935
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
29292936
Assert.That(scene.rightChildReceiver.events, Is.Empty);
@@ -2937,6 +2944,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29372944
Assert.That(scene.leftChildReceiver.events,
29382945
EventSequence(
29392946
OneEvent("type", EventType.Move),
2947+
OneEvent("device", gamepad),
29402948
OneEvent("moveDir", MoveDirection.Up),
29412949
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
29422950
Assert.That(scene.rightChildReceiver.events, Is.Empty);
@@ -2950,6 +2958,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29502958
Assert.That(scene.leftChildReceiver.events,
29512959
EventSequence(
29522960
OneEvent("type", EventType.Move),
2961+
OneEvent("device", gamepad),
29532962
OneEvent("moveDir", MoveDirection.Down),
29542963
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
29552964
Assert.That(scene.rightChildReceiver.events, Is.Empty);
@@ -2964,6 +2973,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29642973
Assert.That(scene.leftChildReceiver.events,
29652974
EventSequence(
29662975
OneEvent("type", EventType.Move),
2976+
OneEvent("device", gamepad),
29672977
OneEvent("moveDir", MoveDirection.Down),
29682978
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
29692979

@@ -2977,6 +2987,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29772987
Assert.That(scene.leftChildReceiver.events,
29782988
EventSequence(
29792989
OneEvent("type", EventType.Move),
2990+
OneEvent("device", gamepad),
29802991
OneEvent("moveDir", MoveDirection.Down),
29812992
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
29822993

@@ -2986,7 +2997,12 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29862997
PressAndRelease(gamepad.buttonSouth);
29872998
yield return null;
29882999

2989-
Assert.That(scene.leftChildReceiver.events, EventSequence(OneEvent("type", EventType.Submit)));
3000+
Assert.That(scene.leftChildReceiver.events,
3001+
EventSequence(
3002+
OneEvent("type", EventType.Submit),
3003+
OneEvent("device", gamepad)
3004+
)
3005+
);
29903006
Assert.That(scene.rightChildReceiver.events, Is.Empty);
29913007

29923008
scene.leftChildReceiver.events.Clear();
@@ -2995,7 +3011,12 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29953011
PressAndRelease(gamepad.buttonEast);
29963012
yield return null;
29973013

2998-
Assert.That(scene.leftChildReceiver.events, EventSequence(OneEvent("type", EventType.Cancel)));
3014+
Assert.That(scene.leftChildReceiver.events,
3015+
EventSequence(
3016+
OneEvent("type", EventType.Cancel),
3017+
OneEvent("device", gamepad)
3018+
)
3019+
);
29993020
Assert.That(scene.rightChildReceiver.events, Is.Empty);
30003021

30013022
scene.leftChildReceiver.events.Clear();
@@ -4463,6 +4484,7 @@ public struct Event
44634484
public BaseEventData data { get; }
44644485
public AxisEventData axisData => (AxisEventData)data;
44654486
public ExtendedPointerEventData pointerData => (ExtendedPointerEventData)data;
4487+
public INavigationEventData navigationData => (INavigationEventData)data;
44664488

44674489
public Event(EventType type, BaseEventData data)
44684490
{
@@ -4521,12 +4543,12 @@ public void OnMove(AxisEventData eventData)
45214543

45224544
public void OnSubmit(BaseEventData eventData)
45234545
{
4524-
events.Add(new Event(EventType.Submit, null));
4546+
events.Add(new Event(EventType.Submit, CloneSubmitCancelEventData(eventData)));
45254547
}
45264548

45274549
public void OnCancel(BaseEventData eventData)
45284550
{
4529-
events.Add(new Event(EventType.Cancel, null));
4551+
events.Add(new Event(EventType.Cancel, CloneSubmitCancelEventData(eventData)));
45304552
}
45314553

45324554
public void OnSelect(BaseEventData eventData)
@@ -4579,11 +4601,20 @@ private static AxisEventData CloneAxisEventData(AxisEventData eventData)
45794601
{
45804602
return new ExtendedAxisEventData(EventSystem.current)
45814603
{
4604+
device = (eventData as ExtendedAxisEventData)?.device,
45824605
moveVector = eventData.moveVector,
45834606
moveDir = eventData.moveDir
45844607
};
45854608
}
45864609

4610+
private static ExtendedSubmitCancelEventData CloneSubmitCancelEventData(BaseEventData eventData)
4611+
{
4612+
return new ExtendedSubmitCancelEventData(EventSystem.current)
4613+
{
4614+
device = (eventData as ExtendedSubmitCancelEventData)?.device
4615+
};
4616+
}
4617+
45874618
private static ExtendedPointerEventData ClonePointerEventData(PointerEventData eventData)
45884619
{
45894620
// InputSystemUIInputModule should only be sending ExtendedPointEventData.

Assets/Tests/InputSystem/Unity.InputSystem.Tests.asmdef

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
"expression": "6000.0.11",
5252
"define": "UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA"
5353
},
54+
{
55+
"name": "Unity",
56+
"expression": "6000.2.0a4",
57+
"define": "UNITY_INPUT_SYSTEM_INPUT_MODULE_NAVIGATION_DEVICE_TYPE"
58+
},
5459
{
5560
"name": "Unity",
5661
"expression": "6000.0.15",

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ however, it has to be formatted properly to pass verification tests.
1010

1111
## [Unreleased] - yyyy-mm-dd
1212

13+
### Fixed
14+
- Fixed an issue where removing a newly created action in the Asset Editor would cause an exception. [UUM-95693](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-95693)
15+
- Fixed arrow key navigation of Input Actions after Action rename. [ISXB-1024](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1024)
16+
- Fixed gamepad navigation in UI Toolkit TextField when using InputSystemUIInputModule. [UUM-77364](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-77364)
17+
- Fixed issue where asset editor window splitter positions were not persisted [ISXB-1316]
18+
1319
## [1.13.0] - 2025-02-05
1420

1521
### Fixed
@@ -22,6 +28,7 @@ however, it has to be formatted properly to pass verification tests.
2228
- Fixed an issue causing InvalidOperationException when entering playmode with domain reload disabled. [ISXB-1208](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1208).
2329
- Fixed an issue where compiling Addressables with Input System package present would result in failed compilation due to `IInputAnalytic.TryGatherData` not being defined [ISXB-1203](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1203).
2430
- Pinned Touch Samples sample package dependencies to avoid errors with Cinemachine 3.x and Probuilder 6.x. [ISXB-1245](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1245)
31+
- Fixed issue where a binding path is sometimes not saved when chosen from the binding path picker. [ISXB-1221](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1221)
2532
- Fixed an issue where dropdown menu for Path in Input Actions Editor could not be selected from any button position. [ISXB-1309](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1309)
2633

2734
## [1.12.0] - 2025-01-15

Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ public InputControlPathEditor(SerializedProperty pathProperty, InputControlPicke
3030
{
3131
if (pathProperty == null)
3232
throw new ArgumentNullException(nameof(pathProperty));
33-
34-
this.pathProperty = pathProperty;
33+
// Update the static pathProperty variable to the most recent serializedProperty.
34+
// See comment on pathProperty for more information.
35+
s_pathProperty = pathProperty;
3536
this.onModified = onModified;
3637
m_PickerState = pickerState ?? new InputControlPickerState();
3738
m_PathLabel = label ?? new GUIContent(pathProperty.displayName, pathProperty.GetTooltip());
3839
}
3940

4041
public void Dispose()
4142
{
43+
s_pathProperty = null;
4244
m_PickerDropdown?.Dispose();
4345
}
4446

@@ -89,10 +91,10 @@ public void OnGUI()
8991
EditorGUILayout.EndHorizontal();
9092
}
9193

94+
//TODO: on next major version remove property argument.
9295
public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty property = null, Action modifiedCallback = null)
9396
{
9497
var pathLabel = label ?? m_PathLabel;
95-
var serializedProperty = property ?? pathProperty;
9698

9799
var lineRect = rect;
98100
var labelRect = lineRect;
@@ -113,7 +115,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
113115
var path = String.Empty;
114116
try
115117
{
116-
path = serializedProperty.stringValue;
118+
path = pathProperty.stringValue;
117119
}
118120
catch
119121
{
@@ -138,8 +140,8 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
138140
path = EditorGUI.DelayedTextField(bindingTextRect, path);
139141
if (EditorGUI.EndChangeCheck())
140142
{
141-
serializedProperty.stringValue = path;
142-
serializedProperty.serializedObject.ApplyModifiedProperties();
143+
pathProperty.stringValue = path;
144+
pathProperty.serializedObject.ApplyModifiedProperties();
143145
(modifiedCallback ?? onModified).Invoke();
144146
}
145147
}
@@ -148,9 +150,9 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
148150
// Dropdown that shows binding text and allows opening control picker.
149151
if (EditorGUI.DropdownButton(bindingTextRect, new GUIContent(displayName), FocusType.Keyboard))
150152
{
151-
SetExpectedControlLayoutFromAttribute(serializedProperty);
153+
SetExpectedControlLayoutFromAttribute(pathProperty);
152154
////TODO: for bindings that are part of composites, use the layout information from the [InputControl] attribute on the field
153-
ShowDropdown(bindingTextRect, serializedProperty, modifiedCallback ?? onModified);
155+
ShowDropdown(bindingTextRect, modifiedCallback ?? onModified);
154156
}
155157
}
156158

@@ -159,7 +161,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
159161
EditorStyles.miniButton);
160162
}
161163

162-
private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Action modifiedCallback)
164+
private void ShowDropdown(Rect rect, Action modifiedCallback)
163165
{
164166
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
165167
InputActionsEditorSettingsProvider.SetIMGUIDropdownVisible(true, false);
@@ -170,19 +172,13 @@ private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Acti
170172
m_PickerState,
171173
path =>
172174
{
173-
serializedProperty.stringValue = path;
175+
pathProperty.stringValue = path;
176+
pathProperty.serializedObject.ApplyModifiedProperties();
174177
m_PickerState.manualPathEditMode = false;
175178
modifiedCallback();
176179
});
177180
}
178181

179-
m_PickerDropdown.SetPickedCallback(path =>
180-
{
181-
serializedProperty.stringValue = path;
182-
m_PickerState.manualPathEditMode = false;
183-
modifiedCallback();
184-
});
185-
186182
m_PickerDropdown.SetControlPathsToMatch(m_ControlPathsToMatch);
187183
m_PickerDropdown.SetExpectedControlLayout(m_ExpectedControlLayout);
188184

@@ -200,7 +196,16 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property)
200196
SetExpectedControlLayout(attribute.layout);
201197
}
202198

203-
public SerializedProperty pathProperty { get; }
199+
// This static variable is a hack. Because the editor is rebuilt at unpredictable times with a new serializedObject, we need to keep updating
200+
// this variable with most up to date serializedProperty, so that the picker dropdown can access the correct serializedProperty.
201+
// The picker dropdown is a separate window and does not have access to the changed serializedObject reference.
202+
// This could be removed if the InputControlPathEditor is converted to UITK with a stable, persistent serializedObject backing this editor.
203+
// This property will be shared among multiple asset editor windows.
204+
private static SerializedProperty s_pathProperty { get; set; }
205+
206+
// This property will always return the most recent serializedProperty.
207+
public SerializedProperty pathProperty { get => s_pathProperty;}
208+
204209
public Action onModified { get; }
205210

206211
private GUIContent m_PathLabel;

Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ public void SetExpectedControlLayout(string expectedControlLayout)
5858
Reload();
5959
}
6060

61-
public void SetPickedCallback(Action<string> action)
62-
{
63-
m_OnPickCallback = action;
64-
}
65-
6661
protected override void OnDestroy()
6762
{
6863
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS

Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ private static void CheckForExtension()
4343
#if UNITY_2023_3_OR_NEWER
4444
BuildTarget.VisionOS,
4545
#endif
46-
#if UNITY_6000_0_OR_NEWER
47-
BuildTarget.ReservedCFE,
48-
#endif
49-
#if UNITY_6000_0_7_OR_NEWER
50-
BuildTarget.Kepler
51-
#endif
5246
BuildTarget.NoTarget
5347
};
5448

Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
4444
}
4545

4646
EditorGUI.BeginProperty(position, label, property);
47-
m_Editor.OnGUI(position, label, property, () => property.serializedObject.ApplyModifiedProperties());
47+
m_Editor.OnGUI(position, label, property: null, modifiedCallback: () => property.serializedObject.ApplyModifiedProperties());
4848
EditorGUI.EndProperty();
4949
}
5050
}

0 commit comments

Comments
 (0)