Skip to content

Commit 9481632

Browse files
authored
FIX: All-numeric names exceeding Int32.MaxValue no longer throw when generating a unique name [UUM-145766] (#2464)
1 parent 8774226 commit 9481632

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Fixed
1111

12+
- Fixed an `OverflowException` when creating a control scheme (or other named item) whose all-numeric name exceeds `Int32.MaxValue`, which previously discarded the entered name and fell back to the default [UUM-145766](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-145766)
1213
- Empty foldouts are no longer shown for processors and interactions that have no settings (e.g. "Invert") [UUM-144325](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-144325)
1314
- Fixed the Input Actions editor toolbar buttons being clipped when the Action Properties panel grew tall enough to show a scrollbar
1415
- Fixed the Control Schemes dropdown in the Input Actions editor continuing to display a deleted scheme's name after the last control scheme was removed, instead of resetting to "No Control Schemes" until the asset was saved or the editor reopened. [UUM-141563](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-141563)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,18 @@ public static string MakeUniqueName<TExisting>(string baseName, IEnumerable<TExi
328328

329329
var name = baseName;
330330
var nameIsUnique = false;
331-
var namesTried = 1;
331+
var namesTried = 1L;
332332

333333
// If the name ends in digits, start counting from the given number.
334334
if (baseName.Length > 0)
335335
{
336336
var lastDigit = baseName.Length;
337337
while (lastDigit > 0 && char.IsDigit(baseName[lastDigit - 1]))
338338
--lastDigit;
339-
if (lastDigit != baseName.Length)
339+
if (lastDigit != baseName.Length &&
340+
long.TryParse(baseName.Substring(lastDigit), out var trailingNumber))
340341
{
341-
namesTried = int.Parse(baseName.Substring(lastDigit)) + 1;
342+
namesTried = trailingNumber + 1;
342343
baseName = baseName.Substring(0, lastDigit);
343344
}
344345
}

0 commit comments

Comments
 (0)