Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Fixed input devices being lost (no keyboard, mouse, gamepad, etc.) after upgrading the package while the Editor is open (related to the recent fast enter playmode change). [ISX-2569]
- Fixed `InputSystemProvider` disabling project-wide actions on shutdown when UI Toolkit destroys its objects mid-play. The provider now scopes its lifecycle to the UI action map only and does not disable project-wide actions [UUM-134130](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-134130)
- Fixed `InputActionRebindingExtensions.GetBindingDisplayString(InputAction, InputBinding, ...)` returning an empty string for composite bindings when the binding mask filters by group [UUM-141423](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-141423)
- Fixed `InputEventPtr.handled` not preventing actions from triggering when switching devices. The default event handled policy has been changed from `SuppressStateUpdates` (now deprecated) to `SuppressActionEventNotifications`, which keeps device state synchronized while suppressing action callbacks for handled events. [ISXB-1097](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1097)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,36 @@
}

var existingStateManagers = Resources.FindObjectsOfTypeAll<InputSystemStateManager>();

// Upgrade migration: package versions up to and including 1.18 stored this state in a
// ScriptableObject named InputSystemObject. That instance survives the domain reload
// triggered by a package upgrade, but the renamed InputSystemStateManager type won't match
// it. Adopt the surviving legacy instance's state into a new state manager so connected
// devices (and other state) are preserved across the upgrade instead of being lost - native
// only re-reports devices once per editor process, so there is no in-process recovery
// otherwise. See ISX-2569.
if (globalReset && (existingStateManagers == null || existingStateManagers.Length == 0))
{
var legacyObjects = Resources.FindObjectsOfTypeAll<InputSystemObject>();
if (legacyObjects != null && legacyObjects.Length > 0)
{
var legacy = legacyObjects[0];
var migrated = ScriptableObject.CreateInstance<InputSystemStateManager>();
migrated.hideFlags = HideFlags.HideAndDontSave;
migrated.systemState = legacy.systemState;
migrated.newInputBackendsCheckedAsEnabled = legacy.newInputBackendsCheckedAsEnabled;
migrated.settings = legacy.settings;
migrated.exitEditModeTime = legacy.exitEditModeTime;
migrated.enterPlayModeTime = legacy.enterPlayModeTime;

Check warning on line 185 in Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs#L174-L185

Added lines #L174 - L185 were not covered by tests

// The legacy instances are no longer needed; get rid of them so we don't migrate twice.
for (var i = 0; i < legacyObjects.Length; ++i)
Object.DestroyImmediate(legacyObjects[i]);

Check warning on line 189 in Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs#L188-L189

Added lines #L188 - L189 were not covered by tests

existingStateManagers = new[] { migrated };
}
}

Check warning on line 193 in Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs#L191-L193

Added lines #L191 - L193 were not covered by tests

if (existingStateManagers != null && existingStateManagers.Length > 0)
{
if (globalReset)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#if UNITY_EDITOR
using UnityEngine;

namespace UnityEngine.InputSystem
{
/// <summary>
/// Legacy compatibility type. Package versions up to and including 1.18 stored the domain-reload
/// survival state in a hidden, <see cref="HideFlags.HideAndDontSave"/> ScriptableObject of this
/// exact type and name (this type was renamed to <see cref="InputSystemStateManager"/> in 1.20).
/// </summary>
/// <remarks>
/// When a project upgrades from such a version, that instance survives the domain reload triggered
/// by the upgrade - but only if its serialized script reference still resolves. That reference is
/// <c>{ fileID: 11500000, guid: &lt;this file's guid&gt; }</c>, so this file MUST keep the original
/// <c>InputSystemObject.cs</c> GUID (<c>5cdce2bffd1e49bda08b3db54a031207</c>) and this MUST be the
/// primary class of the file (matching the file name). If the reference fails to resolve, Unity
/// drops the object during the reload and the input state - including the list of connected devices
/// - is lost on upgrade, with no in-process recovery (native only re-reports devices once per editor
/// process). See ISX-2569.
///
/// The fields below must keep the same names and serialized layout as 1.18's InputSystemObject so the
/// surviving data deserializes into them. <c>InputSystemEditorInitializer.InitializeInEditor</c>
/// detects a surviving instance of this type, migrates its state into a
/// <see cref="InputSystemStateManager"/>, and then destroys it.
/// </remarks>
internal class InputSystemObject : ScriptableObject
{
[SerializeField] public InputSystemState systemState;
[SerializeField] public bool newInputBackendsCheckedAsEnabled;
[SerializeField] public string settings;
[SerializeField] public double exitEditModeTime;
[SerializeField] public double enterPlayModeTime;
}
}
#endif // UNITY_EDITOR

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading