From b2eb798b41053bec1d023dd2370fc4a37b0c741b Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Tue, 9 Sep 2025 14:10:32 +0300 Subject: [PATCH 1/8] fixup warnings with Unity 6.4 relating to the instanceId -> entityId migration --- .../AssetEditor/InputActionEditorWindow.cs | 29 ++++++++++++++----- .../InputActionsEditorWindow.cs | 22 ++++++++++++-- .../InputSystem/InputSystem.cs | 5 ++-- .../InputSystem/Utilities/MiscHelpers.cs | 11 +++++++ 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs index f330f0e348..c2851251d1 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs @@ -42,28 +42,41 @@ static InputActionEditorWindow() InputActionAssetEditor.RegisterType(); } + // Unity 6.4 changed signature of OpenAsset, and now it accepts entity id instead of instance id. + [OnOpenAsset] +#if UNITY_6000_4_OR_NEWER + public static bool OpenAsset(EntityId entityId, int line) + { + if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(entityId))) + return false; + + return OpenAsset(EditorUtility.EntityIdToObject(entityId)); + } +#else + public static bool OpenAsset(int instanceId, int line) + { + if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(instanceId))) + return false; + + return OpenAsset(EditorUtility.InstanceIDToObject(instanceId)); + } +#endif + /// /// Open window if someone clicks on an .inputactions asset or an action inside of it. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "line", Justification = "line parameter required by OnOpenAsset attribute")] - [OnOpenAsset] - public static bool OnOpenAsset(int instanceId, int line) + private static bool OpenAsset(Object obj) { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS if (!InputSystem.settings.useIMGUIEditorForAssets) return false; #endif - var path = AssetDatabase.GetAssetPath(instanceId); - if (!InputActionImporter.IsInputActionAssetPath(path)) - return false; - string mapToSelect = null; string actionToSelect = null; // Grab InputActionAsset. // NOTE: We defer checking out an asset until we save it. This allows a user to open an .inputactions asset and look at it // without forcing a checkout. - var obj = EditorUtility.InstanceIDToObject(instanceId); var asset = obj as InputActionAsset; if (asset == null) { diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs index d469d1e8e5..11edce270f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs @@ -48,18 +48,34 @@ static InputActionsEditorWindow() m_Analytics ??= new InputActionsEditorSessionAnalytic( InputActionsEditorSessionAnalytic.Data.Kind.EditorWindow); + // Unity 6.4 changed signature of OpenAsset, and now it accepts entity id instead of instance id. [OnOpenAsset] - public static bool OpenAsset(int instanceId, int line) +#if UNITY_6000_4_OR_NEWER + public static bool OpenAsset(EntityId entityId, int line) { - if (InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) + if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(entityId))) return false; + + return OpenAsset(EditorUtility.EntityIdToObject(entityId)); + } +#else + public static bool OpenAsset(int instanceId, int line) + { if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(instanceId))) return false; + + return OpenAsset(EditorUtility.InstanceIDToObject(instanceId)); + } +#endif + + private static bool OpenAsset(Object obj) + { + if (InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) + return false; // Grab InputActionAsset. // NOTE: We defer checking out an asset until we save it. This allows a user to open an .inputactions asset and look at it // without forcing a checkout. - var obj = EditorUtility.InstanceIDToObject(instanceId); var asset = obj as InputActionAsset; string actionMapToSelect = null; diff --git a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs index ddcf67418e..9b4a6c536c 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs @@ -3592,8 +3592,7 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) } Debug.Assert(settings != null); - Debug.Assert(EditorUtility.InstanceIDToObject(settings.GetInstanceID()) != null, - "InputSettings has lost its native object"); + Debug.Assert(MiscHelpers.HasNativeObject(settings), "InputSettings has lost its native object"); // If native backends for new input system aren't enabled, ask user whether we should // enable them (requires restart). We only ask once per session and don't ask when @@ -3707,7 +3706,7 @@ private static void OnProjectChange() // temporary settings object. // NOTE: We access m_Settings directly here to make sure we're not running into asserts // from the settings getter checking it has a valid object. - if (EditorUtility.InstanceIDToObject(s_Manager.m_Settings.GetInstanceID()) == null) + if (MiscHelpers.HasNativeObject(s_Manager.m_Settings)) { var newSettings = ScriptableObject.CreateInstance(); newSettings.hideFlags = HideFlags.HideAndDontSave; diff --git a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs index dac1043ece..91688ba264 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using UnityEditor; namespace UnityEngine.InputSystem.Utilities { @@ -36,5 +37,15 @@ public static int IndexOf(this IEnumerable enumerable, TValue va ++index; return -1; } + + // We have this function to hide away instanceId -> entityId migration that happened in Unity 6.4 + public static bool HasNativeObject(Object obj) + { +#if UNITY_6000_4_OR_NEWER + return EditorUtility.EntityIdToObject(obj.GetEntityId()) != null; +#else + return EditorUtility.InstanceIDToObject(obj.GetInstanceID()) != null; +#endif + } } } From c1907669a575781c118d1b1a2f747fade1a46912 Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Tue, 9 Sep 2025 16:18:14 +0300 Subject: [PATCH 2/8] fixup runtime compilation --- .../InputSystem/InputSystem.cs | 14 ++++++++++++-- .../InputSystem/Utilities/MiscHelpers.cs | 10 ---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs index 9b4a6c536c..9287295ef8 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs @@ -3592,7 +3592,7 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) } Debug.Assert(settings != null); - Debug.Assert(MiscHelpers.HasNativeObject(settings), "InputSettings has lost its native object"); + Debug.Assert(HasNativeObject(settings), "InputSettings has lost its native object"); // If native backends for new input system aren't enabled, ask user whether we should // enable them (requires restart). We only ask once per session and don't ask when @@ -3695,6 +3695,16 @@ internal static void OnPlayModeChange(PlayModeStateChange change) } } + // We have this function to hide away instanceId -> entityId migration that happened in Unity 6.4 + public static bool HasNativeObject(Object obj) + { +#if UNITY_6000_4_OR_NEWER + return EditorUtility.EntityIdToObject(obj.GetEntityId()) != null; +#else + return EditorUtility.InstanceIDToObject(obj.GetInstanceID()) != null; +#endif + } + private static void OnProjectChange() { ////TODO: use dirty count to find whether settings have actually changed @@ -3706,7 +3716,7 @@ private static void OnProjectChange() // temporary settings object. // NOTE: We access m_Settings directly here to make sure we're not running into asserts // from the settings getter checking it has a valid object. - if (MiscHelpers.HasNativeObject(s_Manager.m_Settings)) + if (HasNativeObject(s_Manager.m_Settings)) { var newSettings = ScriptableObject.CreateInstance(); newSettings.hideFlags = HideFlags.HideAndDontSave; diff --git a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs index 91688ba264..db653a662c 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs @@ -37,15 +37,5 @@ public static int IndexOf(this IEnumerable enumerable, TValue va ++index; return -1; } - - // We have this function to hide away instanceId -> entityId migration that happened in Unity 6.4 - public static bool HasNativeObject(Object obj) - { -#if UNITY_6000_4_OR_NEWER - return EditorUtility.EntityIdToObject(obj.GetEntityId()) != null; -#else - return EditorUtility.InstanceIDToObject(obj.GetInstanceID()) != null; -#endif - } } } From d1891993fa2acd783a58180d6696a681e57b01aa Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Wed, 10 Sep 2025 10:18:02 +0300 Subject: [PATCH 3/8] suppress the XR warning as per the Slack discussion, with a link to the team ticket --- .../InputSystem/Plugins/XR/TrackedPoseDriver.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs index f4b9e1decc..d3bbea1710 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs @@ -421,7 +421,11 @@ protected virtual void Awake() #if UNITY_INPUT_SYSTEM_ENABLE_VR && ENABLE_VR if (HasStereoCamera(out var cameraComponent)) { + // The Unity 6.4+ replacement for this call has to be figured later + // See https://jira.unity3d.com/browse/XR-7591 +#pragma warning disable CS0618 UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(cameraComponent, true); +#pragma warning restore CS0618 } #endif } @@ -458,7 +462,11 @@ protected virtual void OnDestroy() #if UNITY_INPUT_SYSTEM_ENABLE_VR && ENABLE_VR if (HasStereoCamera(out var cameraComponent)) { + // The Unity 6.4+ replacement for this call has to be figured later + // See https://jira.unity3d.com/browse/XR-7591 +#pragma warning disable CS0618 UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(cameraComponent, false); +#pragma warning restore CS0618 } #endif } From acf556de7ba64d96e1f9b94144702c0ed02aeb44 Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Wed, 10 Sep 2025 10:19:24 +0300 Subject: [PATCH 4/8] apply formatting --- .../Editor/AssetEditor/InputActionEditorWindow.cs | 6 ++++-- .../Editor/UITKAssetEditor/InputActionsEditorWindow.cs | 6 ++++-- .../InputSystem/Plugins/XR/TrackedPoseDriver.cs | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs index c2851251d1..b0b457639f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs @@ -52,15 +52,17 @@ public static bool OpenAsset(EntityId entityId, int line) return OpenAsset(EditorUtility.EntityIdToObject(entityId)); } + #else public static bool OpenAsset(int instanceId, int line) { if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(instanceId))) return false; - + return OpenAsset(EditorUtility.InstanceIDToObject(instanceId)); } -#endif + +#endif /// /// Open window if someone clicks on an .inputactions asset or an action inside of it. diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs index 11edce270f..90aac7d04d 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs @@ -58,15 +58,17 @@ public static bool OpenAsset(EntityId entityId, int line) return OpenAsset(EditorUtility.EntityIdToObject(entityId)); } + #else public static bool OpenAsset(int instanceId, int line) { if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(instanceId))) return false; - + return OpenAsset(EditorUtility.InstanceIDToObject(instanceId)); } -#endif + +#endif private static bool OpenAsset(Object obj) { diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs index d3bbea1710..36f312a1e9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs @@ -425,7 +425,7 @@ protected virtual void Awake() // See https://jira.unity3d.com/browse/XR-7591 #pragma warning disable CS0618 UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(cameraComponent, true); -#pragma warning restore CS0618 +#pragma warning restore CS0618 } #endif } From 24bda4622140aaae41e2fcec84cf1a7d8fa21e71 Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Wed, 10 Sep 2025 10:23:51 +0300 Subject: [PATCH 5/8] update release notes --- Packages/com.unity.inputsystem/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 48b062ee13..96075b67ae 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -24,6 +24,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed an issue in `RebindingUISample` preventing UI navigation without Keyboard and Mouse present. - Fixed an issue in `RebindActionUI` which resulted in active binding not being shown after a scene reload. ISXB-1588. - Fixed an issue in `GamepadIconExample` which resulted in icons for left and right triggers not being displayed after a rebind to the exact same controls. ISXB-1593. +- Fixed the compilation warnings when used with Unity 6.4 (ISX-2349) - Fixed an issue where `InputSystemUIInputModule.localMultiPlayerRoot` could not be set to `null` when using `MultiplayerEventSystem`. [ISXB-1610](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1610) - Fixed an issue in `Keyboard` where the sub-script operator would return a `null` key control for the deprecated key `Key.IMESelected`. Now, an aliased `KeyControl`mapping to the IMESelected bit is returned for compability reasons. It is still strongly advised to not rely on this key since `IMESelected` bit isn't strictly a key and will be removed from the `Key` enumeration type in a future major revision. [ISXB-1541](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1541). From f4eb680570fa169f5c56e04dd3091e383eadc3c8 Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Wed, 10 Sep 2025 11:04:08 +0300 Subject: [PATCH 6/8] Update Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs index db653a662c..86a46e8f86 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using UnityEditor; - namespace UnityEngine.InputSystem.Utilities { internal static class MiscHelpers From e0072183f12278b11a62c130f39083344aa77aa1 Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Wed, 10 Sep 2025 11:05:19 +0300 Subject: [PATCH 7/8] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Packages/com.unity.inputsystem/InputSystem/InputSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs index 9287295ef8..34d4462e22 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs @@ -3716,7 +3716,7 @@ private static void OnProjectChange() // temporary settings object. // NOTE: We access m_Settings directly here to make sure we're not running into asserts // from the settings getter checking it has a valid object. - if (HasNativeObject(s_Manager.m_Settings)) + if (!HasNativeObject(s_Manager.m_Settings)) { var newSettings = ScriptableObject.CreateInstance(); newSettings.hideFlags = HideFlags.HideAndDontSave; From d9c7d889f196c1f22079a4542e6d36c551f83ebc Mon Sep 17 00:00:00 2001 From: Anthony Yakovlev Date: Wed, 10 Sep 2025 12:58:31 +0300 Subject: [PATCH 8/8] Update Packages/com.unity.inputsystem/CHANGELOG.md --- Packages/com.unity.inputsystem/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 96075b67ae..9b80e149bc 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -24,7 +24,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed an issue in `RebindingUISample` preventing UI navigation without Keyboard and Mouse present. - Fixed an issue in `RebindActionUI` which resulted in active binding not being shown after a scene reload. ISXB-1588. - Fixed an issue in `GamepadIconExample` which resulted in icons for left and right triggers not being displayed after a rebind to the exact same controls. ISXB-1593. -- Fixed the compilation warnings when used with Unity 6.4 (ISX-2349) +- Fixed the compilation warnings when used with Unity 6.4 (ISX-2349). - Fixed an issue where `InputSystemUIInputModule.localMultiPlayerRoot` could not be set to `null` when using `MultiplayerEventSystem`. [ISXB-1610](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1610) - Fixed an issue in `Keyboard` where the sub-script operator would return a `null` key control for the deprecated key `Key.IMESelected`. Now, an aliased `KeyControl`mapping to the IMESelected bit is returned for compability reasons. It is still strongly advised to not rely on this key since `IMESelected` bit isn't strictly a key and will be removed from the `Key` enumeration type in a future major revision. [ISXB-1541](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1541).