Skip to content

Commit 079fc41

Browse files
author
Rene Damm
authored
FIX: NullReferenceExceptions in input debugger (#778).
1 parent 9fd1be3 commit 079fc41

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ however, it has to be formatted properly to pass verification tests.
1313

1414
#### Actions
1515

16+
- `NullReferenceException` when the input debugger is open with actions being enabled.
1617
- When selecting a device to add to a control scheme, can now select devices with specific usages, too (e.g. "LeftHand" XRController).
1718

1819
### Changed

Packages/com.unity.inputsystem/InputSystem/Utilities/StringHelpers.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,33 +236,39 @@ public static string Join<TValue>(IEnumerable<TValue> values, string separator)
236236
{
237237
// Optimize for there not being any values or only a single one
238238
// that needs no concatenation.
239-
var firstValue = default(TValue);
239+
var firstValue = default(string);
240240
var valueCount = 0;
241241
StringBuilder result = null;
242242

243243
foreach (var value in values)
244244
{
245+
if (value == null)
246+
continue;
247+
var str = value.ToString();
248+
if (string.IsNullOrEmpty(str))
249+
continue;
250+
245251
++valueCount;
246252
if (valueCount == 1)
247253
{
248-
firstValue = value;
254+
firstValue = str;
249255
continue;
250256
}
251257

252258
if (valueCount == 2)
253259
{
254260
result = new StringBuilder();
255-
result.Append(firstValue.ToString());
261+
result.Append(firstValue);
256262
}
257263

258264
result.Append(separator);
259-
result.Append(value.ToString());
265+
result.Append(str);
260266
}
261267

262268
if (valueCount == 0)
263269
return null;
264270
if (valueCount == 1)
265-
return firstValue.ToString();
271+
return firstValue;
266272

267273
return result.ToString();
268274
}

0 commit comments

Comments
 (0)