Skip to content

Commit 9b79f98

Browse files
authored
Merge branch 'develop' into docs-quality-week-2024-callbackcontext
2 parents 29ab9ab + e8834d4 commit 9b79f98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2674
-627
lines changed

Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ IEnumerator WaitForActionMapRename(int index, bool isActive, double timeoutSecs
5858
#endregion
5959

6060
[Test]
61+
[Ignore("Instability, see ISXB-1284")]
6162
public void CanListActionMaps()
6263
{
6364
var actionMapsContainer = m_Window.rootVisualElement.Q("action-maps-container");
@@ -71,6 +72,7 @@ public void CanListActionMaps()
7172
}
7273

7374
[UnityTest]
75+
[Ignore("Instability, see ISXB-1284")]
7476
public IEnumerator CanCreateActionMap()
7577
{
7678
var button = m_Window.rootVisualElement.Q<Button>("add-new-action-map-button");
@@ -99,6 +101,7 @@ public IEnumerator CanCreateActionMap()
99101
}
100102

101103
[UnityTest]
104+
[Ignore("Instability, see ISXB-1284")]
102105
public IEnumerator CanRenameActionMap()
103106
{
104107
var actionMapsContainer = m_Window.rootVisualElement.Q("action-maps-container");
@@ -147,6 +150,7 @@ public IEnumerator CanRenameActionMap()
147150
}
148151

149152
[UnityTest]
153+
[Ignore("Instability, see ISXB-1284")]
150154
public IEnumerator CanDeleteActionMap()
151155
{
152156
var actionMapsContainer = m_Window.rootVisualElement.Q("action-maps-container");

Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,6 +2405,39 @@ public void PlayerInput_CanDisableAfterAssigningAction_WithControlSchemesAndInte
24052405
player.SetActive(false); // Should cause full rebinding and not assert
24062406
}
24072407

2408+
[Test]
2409+
[Category("PlayerInput")]
2410+
public void PlayerInput_DelegatesAreUpdate_WhenActionMapAddedAfterAssignment()
2411+
{
2412+
var gamepad = InputSystem.AddDevice<Gamepad>();
2413+
2414+
var go = new GameObject();
2415+
var listener = go.AddComponent<MessageListener>();
2416+
var playerInput = go.AddComponent<PlayerInput>();
2417+
playerInput.defaultActionMap = "Other";
2418+
var actionAsset = InputActionAsset.FromJson(kActions);
2419+
playerInput.actions = actionAsset;
2420+
2421+
// Disable the asset while adding another action map to it as none
2422+
// of the actions in the asset can be enabled during modification
2423+
//
2424+
actionAsset.Disable();
2425+
var keyboard = InputSystem.AddDevice<Keyboard>();
2426+
var newActionMap = actionAsset.AddActionMap("NewMap");
2427+
var newAction = newActionMap.AddAction("NewAction");
2428+
newAction.AddBinding("<Keyboard>/k", groups: "Keyboard");
2429+
actionAsset.AddControlScheme("Keyboard").WithRequiredDevice<Keyboard>();
2430+
actionAsset.Enable();
2431+
2432+
playerInput.currentActionMap = newActionMap;
2433+
playerInput.ActivateInput();
2434+
listener.messages.Clear();
2435+
2436+
Press(keyboard.kKey);
2437+
2438+
Assert.That(listener.messages, Has.Exactly(1).With.Property("name").EqualTo("OnNewAction"));
2439+
}
2440+
24082441
private struct Message : IEquatable<Message>
24092442
{
24102443
public string name { get; set; }
@@ -2477,6 +2510,11 @@ public void OnOtherAction(InputValue value)
24772510
messages?.Add(new Message { name = "OnOtherAction", value = value.Get<float>() });
24782511
}
24792512

2513+
public void OnNewAction(InputValue value)
2514+
{
2515+
messages?.Add(new Message { name = "OnNewAction", value = value.Get<float>() });
2516+
}
2517+
24802518
// ReSharper disable once UnusedMember.Local
24812519
public void OnActionWithSpaces(InputValue value)
24822520
{

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ however, it has to be formatted properly to pass verification tests.
3030
- Fixed tooltip support in the UI Toolkit version of the Input Actions Asset editor.
3131
- Fixed documentation to clarify bindings with modifiers `overrideModifiersNeedToBePressedFirst` configuration [ISXB-806](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-806).
3232
- Fixed an issue in `Samples/Visualizers/GamepadVisualizer.unity` sample where the visualization wouldn't handle device disconnects or current device changes properly (ISXB-1243).
33+
- Fixed an issue when displaying Serialized InputAction's Processor properties inside the Inspector window. [ISXB-1269](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1269)
34+
- Fixed an issue with default device selection when adding new Control Scheme.
35+
- Fixed an issue where action map delegates were not updated when the asset already assigned to the PlayerInput component were changed [ISXB-711](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-711).
3336

3437
### Changed
3538
- Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086).
3639
- Changed `OnScreenControl` to automaticaly switch, in Single Player with autoswitch enabled, to the target device control scheme when the first component is enabled to prevent bad interactions when it start.
3740
- Changed paremeter `overrideModifiersNeedToBePressedFirst` to obsolete for `ButtonWithOneModifier`, `ButtonWithTwoModifiers`, `OneModifierComposite` and `TwoModifiersComposite` in favour the new `modifiersOrder` parameter which is more explicit.
3841
- Changed `Samples/Visualizers/GamepadVisualizer.unity` to visualize the control values of the current device instead of the first device.
3942

43+
### Added
44+
- Added new API `InputSystem.settings.useIMGUIEditorForAssets` that should be used in custom `InputParameterEditor` that use both IMGUI and UI Toolkit.
45+
4046
## [1.11.2] - 2024-10-16
4147

4248
### Fixed

Packages/com.unity.inputsystem/DocCodeSamples.Tests.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Unity.InputSystem.DocCodeSamples",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:75469ad4d38634e559750d17036d5f7c"
6+
],
7+
"includePlatforms": [
8+
"Editor"
9+
],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": true,
13+
"precompiledReferences": [],
14+
"autoReferenced": false,
15+
"defineConstraints": [],
16+
"versionDefines": [],
17+
"noEngineReferences": false
18+
}

Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using UnityEngine;
2+
using UnityEngine.InputSystem;
3+
4+
namespace DocCodeSamples.Tests
5+
{
6+
internal class GamepadExample : MonoBehaviour
7+
{
8+
void Start()
9+
{
10+
// Print all connected gamepads
11+
Debug.Log(string.Join("\n", Gamepad.all));
12+
}
13+
14+
void Update()
15+
{
16+
var gamepad = Gamepad.current;
17+
18+
// No gamepad connected.
19+
if (gamepad == null)
20+
{
21+
return;
22+
}
23+
24+
// Check if "Button North" was pressed this frame
25+
if (gamepad.buttonNorth.wasPressedThisFrame)
26+
{
27+
Debug.Log("Button North was pressed");
28+
}
29+
30+
// Check if the button control is being continuously actuated and read its value
31+
if (gamepad.rightTrigger.IsActuated())
32+
{
33+
Debug.Log("Right trigger value: " + gamepad.rightTrigger.ReadValue());
34+
}
35+
36+
// Read left stick value and perform some code based on the value
37+
Vector2 move = gamepad.leftStick.ReadValue();
38+
{
39+
// Use the Vector2 move for the game logic here
40+
}
41+
42+
// Creating haptic feedback while "Button South" is pressed and stopping it when released.
43+
if (gamepad.buttonSouth.wasPressedThisFrame)
44+
{
45+
gamepad.SetMotorSpeeds(0.2f, 1.0f);
46+
}
47+
else if (gamepad.buttonSouth.wasReleasedThisFrame)
48+
{
49+
gamepad.ResetHaptics();
50+
}
51+
}
52+
}
53+
}

Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using UnityEngine;
2+
using UnityEngine.InputSystem;
3+
4+
namespace DocCodeSamples.Tests
5+
{
6+
internal class GamepadHapticsExample : MonoBehaviour
7+
{
8+
bool hapticsArePaused = false;
9+
10+
void Update()
11+
{
12+
var gamepad = Gamepad.current;
13+
14+
// No gamepad connected, no need to continue.
15+
if (gamepad == null)
16+
return;
17+
18+
float leftTrigger = gamepad.leftTrigger.ReadValue();
19+
float rightTrigger = gamepad.rightTrigger.ReadValue();
20+
21+
// Only set motor speeds if haptics were not paused and if trigger is actuated.
22+
// Both triggers must be actuated past 0.2f to start haptics.
23+
if (!hapticsArePaused &&
24+
(gamepad.leftTrigger.IsActuated() || gamepad.rightTrigger.IsActuated()))
25+
gamepad.SetMotorSpeeds(
26+
leftTrigger < 0.2f ? 0.0f : leftTrigger,
27+
rightTrigger < 0.2f ? 0.0f : rightTrigger);
28+
29+
// Toggle haptics "playback" when "Button South" is pressed.
30+
// Notice that if you release the triggers after pausing,
31+
// and press the button again, haptics will resume.
32+
if (gamepad.buttonSouth.wasPressedThisFrame)
33+
{
34+
if (hapticsArePaused)
35+
gamepad.ResumeHaptics();
36+
else
37+
gamepad.PauseHaptics();
38+
39+
hapticsArePaused = !hapticsArePaused;
40+
}
41+
42+
// Notice that if you release the triggers after pausing,
43+
// and press the Start button, haptics will be reset.
44+
if (gamepad.startButton.wasPressedThisFrame)
45+
gamepad.ResetHaptics();
46+
}
47+
}
48+
}

Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)