Skip to content

Commit

Permalink
Merge branch 'develop' into ci/add-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanunity authored Dec 17, 2024
2 parents 44891de + aec5efc commit 75c1574
Show file tree
Hide file tree
Showing 19 changed files with 1,853 additions and 389 deletions.
5 changes: 4 additions & 1 deletion Assets/Tests/InputSystem/CorePerformanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,10 @@ public void Performance_OptimizedControls_ReadingPose4kTimes(OptimizationTestTyp
"InputSystem.onAfterUpdate",
"PreUpdate.NewInputUpdate",
"PreUpdate.InputForUIUpdate",
"FixedUpdate.NewInputFixedUpdate"
"FixedUpdate.NewInputFixedUpdate",
"InputAction.Disable",
"InputAction.Enable",
"InputActionMap.ResolveBindings"
};

[PrebuildSetup(typeof(ProjectWideActionsBuildSetup))]
Expand Down
38 changes: 38 additions & 0 deletions Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2405,6 +2405,39 @@ public void PlayerInput_CanDisableAfterAssigningAction_WithControlSchemesAndInte
player.SetActive(false); // Should cause full rebinding and not assert
}

[Test]
[Category("PlayerInput")]
public void PlayerInput_DelegatesAreUpdate_WhenActionMapAddedAfterAssignment()
{
var gamepad = InputSystem.AddDevice<Gamepad>();

var go = new GameObject();
var listener = go.AddComponent<MessageListener>();
var playerInput = go.AddComponent<PlayerInput>();
playerInput.defaultActionMap = "Other";
var actionAsset = InputActionAsset.FromJson(kActions);
playerInput.actions = actionAsset;

// Disable the asset while adding another action map to it as none
// of the actions in the asset can be enabled during modification
//
actionAsset.Disable();
var keyboard = InputSystem.AddDevice<Keyboard>();
var newActionMap = actionAsset.AddActionMap("NewMap");
var newAction = newActionMap.AddAction("NewAction");
newAction.AddBinding("<Keyboard>/k", groups: "Keyboard");
actionAsset.AddControlScheme("Keyboard").WithRequiredDevice<Keyboard>();
actionAsset.Enable();

playerInput.currentActionMap = newActionMap;
playerInput.ActivateInput();
listener.messages.Clear();

Press(keyboard.kKey);

Assert.That(listener.messages, Has.Exactly(1).With.Property("name").EqualTo("OnNewAction"));
}

private struct Message : IEquatable<Message>
{
public string name { get; set; }
Expand Down Expand Up @@ -2477,6 +2510,11 @@ public void OnOtherAction(InputValue value)
messages?.Add(new Message { name = "OnOtherAction", value = value.Get<float>() });
}

public void OnNewAction(InputValue value)
{
messages?.Add(new Message { name = "OnNewAction", value = value.Get<float>() });
}

// ReSharper disable once UnusedMember.Local
public void OnActionWithSpaces(InputValue value)
{
Expand Down
2 changes: 2 additions & 0 deletions Assets/Tests/InputSystem/Plugins/UITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1793,13 +1793,15 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame()
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == secondPosition));

#if UNITY_2021_2_OR_NEWER
Assert.That(scene.rightChildReceiver.events,
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerMove).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == secondPosition));
#endif

// Pointer 3
Assert.That(scene.rightChildReceiver.events,
Expand Down
4 changes: 4 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ however, it has to be formatted properly to pass verification tests.
- Fixed an issue in `Samples/Visualizers/GamepadVisualizer.unity` sample where the visualization wouldn't handle device disconnects or current device changes properly (ISXB-1243).
- 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)
- Fixed an issue with default device selection when adding new Control Scheme.
- 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).
- Fixed Action properties edition in the UI Toolkit version of the Input Actions Asset editor. [ISXB-1277](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1277)

### Changed
- Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086).
Expand All @@ -41,6 +43,7 @@ however, it has to be formatted properly to pass verification tests.

### Added
- Added new API `InputSystem.settings.useIMGUIEditorForAssets` that should be used in custom `InputParameterEditor` that use both IMGUI and UI Toolkit.
- Added ProfilerMakers to `InputAction.Enable()` and `InputActionMap.ResolveBindings()` to enable gathering of profiling data.

## [1.11.2] - 2024-10-16

Expand Down Expand Up @@ -70,6 +73,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed potential crash on Mac when using stale references to deleted InputDevice objects [ISXB-606](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-606).
- Fixed conditional compilation for non-editor analytics on platforms not enabling analytics.
- Fixed simulated touch input not working with PlayerInput component [ISXB-483](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-483).
- Fixed unused PenState information to determine the displayIndex on platforms providing it. (PLAT-10123)

### Changed
- Renamed editor Resources directories to PackageResources to fix package validation warnings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c"
],
"includePlatforms": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if UNITY_INPUT_SYSTEM_ENABLE_UI

using UnityEngine;
using UnityEngine.InputSystem.UI;

namespace DocCodeSamples.Tests
{
internal class InputSystemUIInputModuleAssignActionsExample : MonoBehaviour
{
// Reference to the InputSystemUIInputModule component, needs to be provided in the Inspector
public InputSystemUIInputModule uiModule;

void Start()
{
// Assign default actions
AssignActions();
}

void AssignActions()
{
if (uiModule != null)
uiModule.AssignDefaultActions();
else
Debug.LogError("InputSystemUIInputModule not found.");
}

void UnassignActions()
{
if (uiModule != null)
uiModule.UnassignActions();
else
Debug.LogError("InputSystemUIInputModule not found.");
}

void OnDestroy()
{
// Unassign actions when the object is destroyed
UnassignActions();
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 75c1574

Please sign in to comment.