-
Notifications
You must be signed in to change notification settings - Fork 328
FIX: Set active input handler to InputManager when package is removed (ISXB-675) #2059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+52
−0
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
73b7bcb
set active input handler to InputManager when package is removed
ritamerkl 7ed68d9
small fixes in comments and names
ritamerkl 51493de
added changelog
ritamerkl ad67dcb
comments fix
ritamerkl ad2419d
Fix for restart editor dialog text
ritamerkl 045b4bf
Fix on comment
ritamerkl ad8f26d
add namespace
ritamerkl 232a017
updated with package manager dependency
ritamerkl 6d7cf65
undo update dependencies
ritamerkl 44f193b
make fix available for 2020.2 and newer
ritamerkl 0112fba
Merge branch 'develop' into fix-input-handling-without-inputsystem
ritamerkl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPackageControl.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #if UNITY_EDITOR | ||
| using System; | ||
| using System.Collections.ObjectModel; | ||
| using UnityEditor; | ||
| using UnityEditor.PackageManager; | ||
|
|
||
|
|
||
| namespace UnityEngine.InputSystem.Editor | ||
| { | ||
| /// <summary> | ||
| /// Force restart if InputSystem package is removed to activate and initialize it on managed side. | ||
| /// Set Project Settings input handling to InputManager 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 | ||
ritamerkl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
ritamerkl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| EditorPlayerSettingHelpers.newSystemBackendsEnabled = false; | ||
| if (EditorUtility.DisplayDialog("Unity editor restart required", "You've removed the input system package. This requires a restart of the Editor.", "Restart Editor", "Ignore (Not recommended)")) | ||
ritamerkl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| EditorApplication.OpenProject(Environment.CurrentDirectory); | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
2 changes: 2 additions & 0 deletions
2
Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPackageControl.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.