Skip to content
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed pasting bindings into empty Input Action asset. [ISXB-1180](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1180)
- Fixed missing '&' symbol in Control Scheme dropdown on Windows platform. [ISXB-1109](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1109)
- Fixed icon scaling in Input Actions window.
- Fixed an issue where removing the InputSystem package could lead to invalid input handling settings.
- Fixed `ArgumentOutOfRangeException` when adding a new Control Scheme with any Device selected. [ISXB-1129](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1129)

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#if UNITY_EDITOR && UNITY_2020_2_OR_NEWER
using System;
using System.Collections.ObjectModel;
using UnityEditor;
using UnityEditor.PackageManager;

namespace UnityEngine.InputSystem.Editor
{
/// <summary>
/// Forces the Editor to restart if the InputSystem package is removed to activate and initialize it on the managed side.
/// Automatically sets "Project Settings > Player > Active Input Handling" to "Input Manager" once the package is removed.
/// </summary>
internal class InputSystemPackageControl
{
const string packageName = "com.unity.inputsystem";

[InitializeOnLoadMethod]
static void SubscribePackageManagerEvent()
{
//There's a number of cases where it might not be called, for instance if the user changed the project manifest and deleted the Library folder before opening the project
UnityEditor.PackageManager.Events.registeringPackages += CheckForInputSystemPackageRemoved;
}

private static void CheckForInputSystemPackageRemoved(PackageRegistrationEventArgs packageArgs)
{
if (IsInputSystemRemoved(packageArgs.removed))
HandleInputSystemRemoved();
}

private static bool IsInputSystemRemoved(ReadOnlyCollection<UnityEditor.PackageManager.PackageInfo> packages)
{
foreach (var package in packages)
{
if (package.name == packageName)
return true;
}
return false;
}

private static void HandleInputSystemRemoved()
{
//Set input handling to InputManager
EditorPlayerSettingHelpers.newSystemBackendsEnabled = false;
if (EditorUtility.DisplayDialog("The Unity Editor needs to be restarted", "You've removed the Input System package. This requires a restart of the Unity Editor.", "Restart the Editor", "Ignore (Not recommended)"))
EditorApplication.OpenProject(Environment.CurrentDirectory);
}
}
}
#endif

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