Skip to content

Commit af10098

Browse files
FIX: Fix Precompiled Layouts for types with no namespace (ISXB-552) (#1702)
* Fix GenerateCodeForDeviceLayout when the layout does not have a namespace * move CHANGELOG entry after merge with develop * run code formatter --------- Co-authored-by: James McGill <jamesmcgill@users.noreply.github.com> Co-authored-by: James McGill <james.mcgill@unity3d.com>
1 parent 37ee762 commit af10098

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ however, it has to be formatted properly to pass verification tests.
2222
- Fixed Tracked Pose Driver to use `Transform.SetLocalPositionAndRotation` when available to improve performance. Based on the user contribution from [DevDunk](https://forum.unity.com/members/devdunk.4432119/) in a [forum post](https://forum.unity.com/threads/more-performant-tracked-pose-driver-solution-included.1462691).
2323
- Fixed the `Clone` methods of `InputAction` and `InputActionMap` so it copies the Initial State Check flag (`InputAction.wantsInitialStateCheck`) of input actions.
2424
- Fixed the "Release tests throws exception in InputSystem" bug ([case ISXB-581](https://issuetracker.unity3d.com/issues/release-tests-fail-when-input-system-package-is-installed)).
25+
- Fixed issues with generating Precompiled Layouts for devices which are not defined in a namespace
2526

2627
## [1.6.3] - 2023-07-11
2728

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,17 @@ public static unsafe string GenerateCodeForDeviceLayout(string layoutName, strin
110110
writer.WriteLine("// that we don't end up using.");
111111
writer.WriteLine("#pragma warning disable CS0219");
112112
writer.WriteLine("");
113-
if (@namespace != "")
113+
if (!string.IsNullOrEmpty(@namespace))
114+
{
114115
writer.WriteLine("namespace " + @namespace);
115-
writer.BeginBlock();
116+
writer.BeginBlock();
117+
}
118+
119+
if (string.IsNullOrEmpty(baseTypeNamespace))
120+
writer.WriteLine($"{visibility} partial class {namePrefix}{baseTypeName} : {baseTypeName}");
121+
else
122+
writer.WriteLine($"{visibility} partial class {namePrefix}{baseTypeName} : {baseTypeNamespace}.{baseTypeName}");
116123

117-
writer.WriteLine($"{visibility} partial class {namePrefix}{baseTypeName} : {baseTypeNamespace}.{baseTypeName}");
118124
writer.BeginBlock();
119125

120126
// "Metadata". ATM this is simply a flat, semicolon-separated list of names for layouts and processors that
@@ -304,7 +310,9 @@ public static unsafe string GenerateCodeForDeviceLayout(string layoutName, strin
304310
}
305311

306312
writer.EndBlock();
307-
writer.EndBlock();
313+
314+
if (!string.IsNullOrEmpty(@namespace))
315+
writer.EndBlock();
308316

309317
if (defines != null)
310318
writer.WriteLine($"#endif // {defines}");

0 commit comments

Comments
 (0)