diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 10d6a60fa3..f75369861c 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -11,6 +11,7 @@ however, it has to be formatted properly to pass verification tests. ## [Unreleased] - yyyy-mm-dd ### Fixed +- Fixed a problem with the logic to get the active player settings object that cause an infinit reimport loop. [ISXB-1430](https://jira.unity3d.com/browse/ISXB-1430) - Fixed an issue where removing a newly created action in the Asset Editor would cause an exception. [UUM-95693](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-95693) - Fixed arrow key navigation of Input Actions after Action rename. [ISXB-1024](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1024) - Fixed gamepad navigation in UI Toolkit TextField when using InputSystemUIInputModule. [UUM-77364](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-77364) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/EditorPlayerSettingHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/EditorPlayerSettingHelpers.cs index 2ba6b50711..dc45b3f4c6 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/EditorPlayerSettingHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/EditorPlayerSettingHelpers.cs @@ -3,6 +3,11 @@ using System.Linq; using UnityEditor; +#if UNITY_6000_0_OR_NEWER +using System.Reflection; +using UnityEditor.Build.Profile; +#endif + namespace UnityEngine.InputSystem.Editor { internal static class EditorPlayerSettingHelpers @@ -154,7 +159,33 @@ private static int TupleToActiveInputHandler((bool newSystemEnabled, bool oldSys private static SerializedProperty GetPropertyOrNull(string name) { +#if UNITY_6000_0_OR_NEWER + // HOTFIX: the code below works around an issue causing an infinite reimport loop + // this will be replaced by a call to an API in the editor instead of using reflection once it is available + var buildProfileType = typeof(BuildProfile); + var globalPlayerSettingsField = buildProfileType.GetField("s_GlobalPlayerSettings", BindingFlags.Static | BindingFlags.NonPublic); + if (globalPlayerSettingsField == null) + { + Debug.LogError($"Could not find global player settings field in build profile when trying to get property {name}. Please try to update the Input System package."); + return null; + } + var playerSettings = (PlayerSettings)globalPlayerSettingsField.GetValue(null); + var activeBuildProfile = BuildProfile.GetActiveBuildProfile(); + if (activeBuildProfile != null) + { + var playerSettingsOverrideField = buildProfileType.GetField("m_PlayerSettings", BindingFlags.Instance | BindingFlags.NonPublic); + if (playerSettingsOverrideField == null) + { + Debug.LogError($"Could not find player settings override field in build profile when trying to get property {name}. Please try to update the Input System package."); + return null; + } + var playerSettingsOverride = (PlayerSettings)playerSettingsOverrideField.GetValue(activeBuildProfile); + if (playerSettingsOverride != null) + playerSettings = playerSettingsOverride; + } +#else var playerSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); +#endif if (playerSettings == null) return null; var playerSettingsObject = new SerializedObject(playerSettings);