Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,43 @@
InputActionAssetEditor.RegisterType<InputActionEditorWindow>();
}

// 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)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I read this code myself, I could have left IsInputActionAssetPath in OpenAsset, just the GetAssetPath thing is different. IDK, either way goes fine by my books

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: But I would agree with you, that if it makes the "fork condition" slimmer it is a good idea.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But its also fine as-is

return false;

Check warning on line 51 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs#L49-L51

Added lines #L49 - L51 were not covered by tests

return OpenAsset(EditorUtility.EntityIdToObject(entityId));
}

Check warning on line 54 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs#L53-L54

Added lines #L53 - L54 were not covered by tests

#else
public static bool OpenAsset(int instanceId, int line)
{
if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(instanceId)))
return false;

Check warning on line 60 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs#L58-L60

Added lines #L58 - L60 were not covered by tests

return OpenAsset(EditorUtility.InstanceIDToObject(instanceId));
}

Check warning on line 63 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs#L62-L63

Added lines #L62 - L63 were not covered by tests

#endif

/// <summary>
/// Open window if someone clicks on an .inputactions asset or an action inside of it.
/// </summary>
[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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,36 @@
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)))

Check warning on line 56 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs#L56

Added line #L56 was not covered by tests
return false;

return OpenAsset(EditorUtility.EntityIdToObject(entityId));
}

Check warning on line 60 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs#L59-L60

Added lines #L59 - L60 were not covered by tests

#else
public static bool OpenAsset(int instanceId, int line)
{

Check warning on line 64 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs#L64

Added line #L64 was not covered by tests
if (!InputActionImporter.IsInputActionAssetPath(AssetDatabase.GetAssetPath(instanceId)))
return false;

return OpenAsset(EditorUtility.InstanceIDToObject(instanceId));
}

Check warning on line 69 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs#L68-L69

Added lines #L68 - L69 were not covered by tests

#endif

private static bool OpenAsset(Object obj)
{
if (InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets))
return false;

Check warning on line 76 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs#L74-L76

Added lines #L74 - L76 were not covered by tests

// 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;
Expand Down
15 changes: 12 additions & 3 deletions Packages/com.unity.inputsystem/InputSystem/InputSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Hmmm.... This diff was hard to review but just a thought.

What if this code was changed so that HasNativeObject(Object) would call another function:

Object GetObjectFromEntityID(EntityId id) { <same #if dance to map to EditorUtility> }

And then using a conditional alias where needed for EntityId, e.g.

#if !UNITY_6000_4_OR_NEWER
using EntityId = int;
#endif

Would that eliminate all other branches?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it just makes things weird if entity id and instance id are fundamentally different, if not maybe its something....

{
#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
Expand All @@ -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<InputSettings>();
newSettings.hideFlags = HideFlags.HideAndDontSave;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
#endif
}
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;

namespace UnityEngine.InputSystem.Utilities
{
internal static class MiscHelpers
Expand Down