Skip to content

Commit f5bf847

Browse files
FIX: InputActionMap warnings when the UI map is not setup correctly (ISXB-1560) (#2229)
1 parent d6f4d02 commit f5bf847

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Assets/Tests/InputSystem/Plugins/InputForUITests.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,19 +535,31 @@ public void DefaultActions_ShouldNotGenerateAnyVerificationWarnings(bool useProj
535535
LogAssert.NoUnexpectedReceived();
536536
}
537537

538-
[Ignore("We currently allow a PWA asset without an UI action map and rely on defaults instead. This allows users that do not want it or use something else to avoid using it.")]
539-
[Test(Description = "Verifies that user-supplied project-wide input actions generates warnings if action map is missing.")]
538+
[Test(Description = "Verifies that user-supplied project-wide actions do not generate warnings if action map is missing. We use default actions in this case.")]
540539
[Category(kTestCategory)]
541-
public void ActionsWithoutUIMap_ShouldGenerateWarnings()
540+
public void ActionsWithoutUIMap_ShouldNotGenerateWarnings()
542541
{
543542
var asset = ProjectWideActionsAsset.CreateDefaultAssetAtPath(kAssetPath);
544543
asset.RemoveActionMap(asset.FindActionMap("UI", throwIfNotFound: true));
545544

546545
InputSystem.s_Manager.actions = asset;
547546
Update();
548547

548+
LogAssert.NoUnexpectedReceived();
549+
}
550+
551+
[Test(Description = "Verifies that user-supplied project-wide input actions generates warnings if the UI map is present but actions are missing.")]
552+
[Category(kTestCategory)]
553+
public void ActionsWithUIMap_MissingActions_ShouldGenerateWarnings()
554+
{
555+
var asset = ProjectWideActionsAsset.CreateDefaultAssetAtPath(kAssetPath);
556+
asset.RemoveActionMap(asset.FindActionMap("UI", throwIfNotFound: true));
557+
asset.AddActionMap(new InputActionMap("UI")); // An empty UI map should log warnings.
558+
559+
InputSystem.s_Manager.actions = asset;
560+
Update();
561+
549562
var link = EditorHelpers.GetHyperlink(kAssetPath);
550-
LogAssert.Expect(LogType.Warning, new Regex($"^InputActionMap with path 'UI' in asset '{link}' could not be found."));
551563
if (InputActionAssetVerifier.DefaultReportPolicy == InputActionAssetVerifier.ReportPolicy.ReportAll)
552564
{
553565
LogAssert.Expect(LogType.Warning, new Regex($"^InputAction with path 'UI/Point' in asset '{link}' could not be found."));
@@ -559,8 +571,6 @@ public void ActionsWithoutUIMap_ShouldGenerateWarnings()
559571
LogAssert.Expect(LogType.Warning, new Regex($"^InputAction with path 'UI/RightClick' in asset '{link}' could not be found."));
560572
LogAssert.Expect(LogType.Warning, new Regex($"^InputAction with path 'UI/ScrollWheel' in asset '{link}' could not be found."));
561573
}
562-
// else: expect suppression of child errors
563-
LogAssert.NoUnexpectedReceived();
564574
}
565575

566576
[Test(Description = "Verifies that user-supplied project-wide input actions generates warnings if any required action is missing.")]

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ however, it has to be formatted properly to pass verification tests.
3131
### Fixed
3232
- Fixed an issue where using Pen devices on Android tablets would result in double clicks for UI interactions. [ISXB-1456](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1456)
3333
- Fixed an issue preventing an embedded platform from being released. It adds back some `#defines` to `XRSupport` and `InputDeviceCharacteristics`.
34+
- Fixed a warning not showing the asset name correctly when the input action map parameters for runtime GUI were not setup. [ISXB-1560]
3435

3536
## [1.14.1] - 2025-07-10
3637

Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputActionAssetVerifier.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ static InputActionAssetVerifier()
3232
public void Verify(InputActionAsset asset,
3333
ProjectWideActionsAsset.IReportInputActionAssetVerificationErrors reporter)
3434
{
35+
// We don't want to log warnings if no UI action map is present as we default in this case.
36+
if (asset.FindActionMap("UI", false) == null)
37+
{
38+
return;
39+
}
40+
3541
// Note:
3642
// PWA has initial state check true for "Point" action, DefaultActions do not, does it matter?
3743
//
@@ -70,7 +76,7 @@ public Context(InputActionAsset asset,
7076
private string GetAssetReference()
7177
{
7278
var path = AssetDatabase.GetAssetPath(asset);
73-
return path ?? asset.name;
79+
return string.IsNullOrEmpty(path) ? asset.name : path;
7480
}
7581

7682
private void ActionMapWarning(string actionMap, string problem)

0 commit comments

Comments
 (0)