-
Notifications
You must be signed in to change notification settings - Fork 329
NEW: Throw error when extension for inputsystem needed #2101
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
ritamerkl
merged 20 commits into
develop
from
throw-error-nda-inputsystem-without-plugin
Jan 10, 2025
Merged
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
094ef6a
added checking for build target to throw an error if no plugin present
ritamerkl dde9e4b
adjusted error message - some formatting
ritamerkl 6f1b2e3
added changelog
ritamerkl f086f66
Merge branch 'throw-error-nda-inputsystem-without-plugin' of https://…
ritamerkl 240dd15
fix formatting
ritamerkl b72c6ab
added minimum versions for build targets and plugin control
ritamerkl 8300377
remove LINQ usage
ritamerkl b04d51d
only run in editor
ritamerkl 2fbe470
removed unused reference
ritamerkl 65000be
make InputSystemPluginControl internal
ritamerkl 9bec99d
fixed switched logic
ritamerkl 16479d4
Removed PS5 from list
ritamerkl 9c5879e
Added Comment to clarify timing
ritamerkl cf2863a
changed plugin control to be check platform name and added register e…
ritamerkl 16f46df
added documentation
ritamerkl 10c4c08
tweaked comment to explain event ordering
ritamerkl 15c4d2d
refactored to add and remove buildtargets to a set
ritamerkl 696b057
added docs generation to ifdef
ritamerkl e7f7b63
edited comments and small refactor of names (PR fix)
ritamerkl 931fa48
Merge branch 'develop' into throw-error-nda-inputsystem-without-plugin
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
100 changes: 100 additions & 0 deletions
100
Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.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,100 @@ | ||
| #if UNITY_EDITOR | ||
| #if UNITY_2021_1_OR_NEWER | ||
| using System; | ||
| using UnityEditor; | ||
|
|
||
| namespace UnityEngine.InputSystem.Editor | ||
| { | ||
| /// <summary> | ||
| /// This class controls all required plugins and extension packages are installed for the InputSystem. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// For some platforms, the InputSystem requires additional plugins to be installed. This class checks if the required plugins are installed and throws a warning if they are not. | ||
| /// </remarks> | ||
| public class InputSystemPluginControl | ||
| { | ||
| //At the time of InitializeOnLoad the packages are compiled and registered | ||
| [InitializeOnLoadMethod] | ||
| private static void CheckForExtension() | ||
| { | ||
| ThrowWarningOnMissingPlugin(); | ||
| m_pluginPackageRegistered = false; | ||
| } | ||
|
|
||
| private static readonly BuildTarget[] TargetNoPluginNeeded = | ||
| { | ||
| BuildTarget.StandaloneOSX, | ||
| BuildTarget.StandaloneWindows, | ||
| BuildTarget.iOS, | ||
| BuildTarget.Android, | ||
| BuildTarget.StandaloneWindows64, | ||
| BuildTarget.WebGL, | ||
| BuildTarget.WSAPlayer, | ||
| BuildTarget.StandaloneLinux64, | ||
| BuildTarget.tvOS, | ||
| BuildTarget.LinuxHeadlessSimulation, | ||
| BuildTarget.EmbeddedLinux, | ||
| #if UNITY_2022_1_OR_NEWER | ||
| BuildTarget.QNX, | ||
| #endif | ||
| #if UNITY_2023_3_OR_NEWER | ||
| BuildTarget.VisionOS, | ||
| #endif | ||
| #if UNITY_6000_0_OR_NEWER | ||
| BuildTarget.ReservedCFE, | ||
| #endif | ||
| #if UNITY_6000_0_7_OR_NEWER | ||
| BuildTarget.Kepler | ||
| #endif | ||
| BuildTarget.NoTarget | ||
| }; | ||
|
|
||
| private static bool m_pluginPackageRegistered = false; | ||
|
|
||
| static bool BuildTargetNeedsPlugin() | ||
| { | ||
| BuildTarget target = EditorUserBuildSettings.activeBuildTarget; | ||
| foreach (var platform in TargetNoPluginNeeded) | ||
| { | ||
| if (platform == target) return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| private const string PlugInName = "com.unity.inputsystem."; | ||
|
|
||
| /// <summary> | ||
| /// Used to register extensions externally to the InputSystem, this is needed for all Platforms that require a plugin to be installed. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This method is internally called by the InputSystem package extensions to register the PlugIn. This can be called for custom extensions on custom platforms. | ||
| /// </remarks> | ||
| public static void RegisterPluginPackage() | ||
| { | ||
| m_pluginPackageRegistered = true; | ||
| } | ||
|
|
||
| private static bool IsPluginInstalled() | ||
| { | ||
| if (m_pluginPackageRegistered) | ||
| return true; | ||
| var registeredPackages = UnityEditor.PackageManager.PackageInfo.GetAllRegisteredPackages(); | ||
| var plugInName = PlugInName + EditorUserBuildSettings.activeBuildTarget.ToString().ToLower(); | ||
| foreach (var package in registeredPackages) | ||
lyndon-unity marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if (package.name.Equals(plugInName)) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private static void ThrowWarningOnMissingPlugin() | ||
| { | ||
| if (!BuildTargetNeedsPlugin()) | ||
| return; | ||
| Debug.Assert(IsPluginInstalled(), "Active Input Handling is set to InputSystem, but no Plugin for " + EditorUserBuildSettings.activeBuildTarget + " was found. Please install the missing InputSystem package extensions."); | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
| #endif | ||
2 changes: 2 additions & 0 deletions
2
Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.