Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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 @@ -45,6 +45,7 @@ however, it has to be formatted properly to pass verification tests.
### Added
- Added new API `InputSystem.settings.useIMGUIEditorForAssets` that should be used in custom `InputParameterEditor` that use both IMGUI and UI Toolkit.
- Added ProfilerMakers to `InputAction.Enable()` and `InputActionMap.ResolveBindings()` to enable gathering of profiling data.
- Added throwing an error message when trying to use the Input System package on console without the extension package installed.

## [1.11.2] - 2024-10-16

Expand Down
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)
{
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

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

Loading