diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 48b062ee13..9b80e149bc 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). diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs index f330f0e348..b0b457639f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs @@ -42,28 +42,43 @@ 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..90aac7d04d 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs @@ -48,18 +48,36 @@ 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..34d4462e22 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(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 @@ -3696,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 @@ -3707,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 (EditorUtility.InstanceIDToObject(s_Manager.m_Settings.GetInstanceID()) == null) + if (!HasNativeObject(s_Manager.m_Settings)) { var newSettings = ScriptableObject.CreateInstance(); newSettings.hideFlags = HideFlags.HideAndDontSave; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs index f4b9e1decc..36f312a1e9 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 } diff --git a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs index dac1043ece..86a46e8f86 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Utilities/MiscHelpers.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; - namespace UnityEngine.InputSystem.Utilities { internal static class MiscHelpers