From d6b0447ddc1d1bff8a19ffc3f0d5f3b7ed8e6b07 Mon Sep 17 00:00:00 2001 From: Paulius Dervinis Date: Wed, 5 Aug 2026 11:02:31 +0300 Subject: [PATCH 1/3] FIX: All-numeric names exceeding Int32.MaxValue no longer throw when generating a unique name [UUM-145766] StringHelpers.MakeUniqueName threw an OverflowException when generating a unique name from an all-numeric base name whose value exceeded Int32.MaxValue, causing the entered control scheme name to be discarded in favour of the default "New Control Scheme". StringHelpers.MakeUniqueName(string baseName, IEnumerable existingSet, Func getNameFunc) parsed the trailing digit run with int.Parse, which overflows for values above Int32.MaxValue. It now uses int.TryParse and, when the parse fails, keeps the full name as the base rather than stripping the digit suffix, so a numeric suffix is appended to make the name unique instead of an exception being thrown. Jira: https://jira.unity3d.com/browse/UUM-145766 --- Packages/com.unity.inputsystem/CHANGELOG.md | 1 + .../InputSystem/Runtime/Utilities/StringHelpers.cs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 959e81cc4d..b7f32ec01c 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed +- 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) - Fixed the Input Debugger window (Window > Analysis > Input Debugger) being resizable arbitrarily small until its toolbar and device/action/layout tree view were no longer usably visible; it now enforces a minimum window size [UUM-137119](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-137119) - Fixed the Action Maps list in the Input Actions editor losing keyboard focus after deleting a map, so that Delete, Duplicate, and arrow-key navigation kept working on the auto-selected replacement map without requiring an extra click [UUM-147152](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-147152) diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs index 56991ebe5b..2f78a80bdf 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs @@ -336,9 +336,10 @@ public static string MakeUniqueName(string baseName, IEnumerable 0 && char.IsDigit(baseName[lastDigit - 1])) --lastDigit; - if (lastDigit != baseName.Length) + if (lastDigit != baseName.Length && + int.TryParse(baseName.Substring(lastDigit), out var trailingNumber)) { - namesTried = int.Parse(baseName.Substring(lastDigit)) + 1; + namesTried = trailingNumber + 1; baseName = baseName.Substring(0, lastDigit); } } From c12cce376f5d981898fdfdb7321cf1f4a8e27404 Mon Sep 17 00:00:00 2001 From: Paulius Dervinis Date: Wed, 5 Aug 2026 11:12:06 +0300 Subject: [PATCH 2/3] FIX: Widen unique-name counter to long so an Int32.MaxValue name suffix cannot overflow [UUM-145766] Guard the collision counter against overflowing when the trailing digits equal Int32.MaxValue. When an all-numeric base name parsed to exactly Int32.MaxValue, seeding the counter with trailingNumber + 1 overflowed int and the collision loop produced negative suffixes. The counter is now a long and the seeding addition is widened, so the suffix continues past Int32.MaxValue as a positive number. Jira: https://jira.unity3d.com/browse/UUM-145766 --- .../InputSystem/Runtime/Utilities/StringHelpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs index 2f78a80bdf..8cadbf3b02 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs @@ -328,7 +328,7 @@ public static string MakeUniqueName(string baseName, IEnumerable 0) @@ -339,7 +339,7 @@ public static string MakeUniqueName(string baseName, IEnumerable Date: Wed, 5 Aug 2026 12:27:59 +0300 Subject: [PATCH 3/3] FIX: Parse the trailing digit run with long.TryParse to match the widened counter [UUM-145766] Parse the trailing numeric suffix as a long so names whose digits exceed Int32.MaxValue seed the counter instead of falling through to the append path. With namesTried already a long, long.TryParse lets a name like "item2147483648" increment to "item2147483649" on collision, rather than failing int.TryParse and producing "item21474836481". A name is only treated as an unseeded base when its digit run exceeds Int64.MaxValue. Jira: https://jira.unity3d.com/browse/UUM-145766 --- .../InputSystem/Runtime/Utilities/StringHelpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs index 8cadbf3b02..6a0e9937ee 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs @@ -337,9 +337,9 @@ public static string MakeUniqueName(string baseName, IEnumerable 0 && char.IsDigit(baseName[lastDigit - 1])) --lastDigit; if (lastDigit != baseName.Length && - int.TryParse(baseName.Substring(lastDigit), out var trailingNumber)) + long.TryParse(baseName.Substring(lastDigit), out var trailingNumber)) { - namesTried = (long)trailingNumber + 1; + namesTried = trailingNumber + 1; baseName = baseName.Substring(0, lastDigit); } }