Skip to content

Commit

Permalink
changed plugin control to be check platform name and added register e…
Browse files Browse the repository at this point in the history
…xtention package method
  • Loading branch information
ritamerkl committed Jan 7, 2025
1 parent 9c5879e commit cf2863a
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

namespace UnityEngine.InputSystem.Editor
{
internal class InputSystemPluginControl
/// <summary>
/// This class controls all required plugins and extension packages are installed for the InputSystem.
/// </summary>
public class InputSystemPluginControl
{
//At the time of InitializeOnLoad the packages are compiled and registered
[InitializeOnLoadMethod]
Expand Down Expand Up @@ -42,6 +45,8 @@ private static void CheckForExtension()
BuildTarget.NoTarget
};

private static bool m_pluginPackageRegistered = false;

static bool BuildTargetNeedsPlugin()
{
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
Expand All @@ -54,12 +59,23 @@ static bool BuildTargetNeedsPlugin()

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>
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.StartsWith(PlugInName))
if (package.name.Equals(plugInName))
return true;
}
return false;
Expand Down

0 comments on commit cf2863a

Please sign in to comment.