Skip to content

Commit

Permalink
refactored to add and remove buildtargets to a set
Browse files Browse the repository at this point in the history
  • Loading branch information
ritamerkl committed Jan 8, 2025
1 parent 10c4c08 commit 15c4d2d
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if UNITY_EDITOR
#if UNITY_2021_1_OR_NEWER
using System;
using System.Collections.Generic;
using UnityEditor;

namespace UnityEngine.InputSystem.Editor
Expand All @@ -20,10 +21,10 @@ public class InputSystemPluginControl
private static void CheckForExtension()
{
ThrowWarningOnMissingPlugin();
m_pluginPackageRegistered = false;
}

private static readonly BuildTarget[] TargetNoPluginNeeded =
//This static HashSet will be reset OnDomainReload and so it will be emptied and refilled every [InitializeOnLoad]]
private static HashSet<BuildTarget> s_targetNoPluginNeeded = new HashSet<BuildTarget>()
{
BuildTarget.StandaloneOSX,
BuildTarget.StandaloneWindows,
Expand Down Expand Up @@ -51,12 +52,10 @@ private static void CheckForExtension()
BuildTarget.NoTarget
};

private static bool m_pluginPackageRegistered = false;

static bool BuildTargetNeedsPlugin()
{
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
foreach (var platform in TargetNoPluginNeeded)
foreach (var platform in s_targetNoPluginNeeded)
{
if (platform == target) return false;
}
Expand All @@ -73,13 +72,12 @@ static bool BuildTargetNeedsPlugin()
/// </remarks>
public static void RegisterPlatform(BuildTarget target)
{
m_pluginPackageRegistered = true;
if (EditorUserBuildSettings.activeBuildTarget == target)
s_targetNoPluginNeeded.Add(target);
}

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

0 comments on commit 15c4d2d

Please sign in to comment.