Skip to content

Conversation

@ritamerkl
Copy link
Collaborator

@ritamerkl ritamerkl commented Feb 5, 2024

Description

This PR adds Drag & Drop support for the UITK-Editor. Find the ticket here.
Basically it includes reordering and moving of ActionMaps, Actions and Bindings in the Editor.

Changes made

added:

  • reordering ActionMaps
  • moving Actions to other ActionMaps
  • reordering Actions
  • moving Bindings and Composites to other Actions or reorder Bindings/Composites in the same Action
  • moving Composite parts from one Composite to other Composites or reordering them in the same Composite

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

jfreire-unity and others added 30 commits August 14, 2023 13:11
…-and-drop

# Conflicts:
#	Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs
#	Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionMapsView.cs
#	Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs
…-and-drop

# Conflicts:
#	Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionMapsView.cs
@graham-huws
Copy link
Collaborator

Added a couple minor things, nothing really to add beyond what Håkan mentioned - I'm always a fan of more comments explaining functions though :)

Copy link
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

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

Things I noticed so far:

  • I can drop composite bindings into non composite actions (and vice versa) -> after dragging them they jump back to where they were. Expected: block symbol on mouse is shown and you can't drag them there at all
  • Undo naming is not user friendly shown as "Modified Actions Maps.Array..." or "Modified x# properties"
    Expected: "Moved Action/Binding x" does not need to go into specifics where it was moved, just has to be human readable of what action was done
  • Unknown steps to error so far but got it when loading the ProjectWideActions test scene (ignore if cause not clear from error message alone):
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.InputSystem.InputActionMap.Disable () (at ./Packages/com.unity.inputsystem/InputSystem/Actions/InputActionMap.cs:559)
UnityEngine.InputSystem.InputActionAsset.Disable () (at ./Packages/com.unity.inputsystem/InputSystem/Actions/InputActionAsset.cs:818)
UnityEngine.InputSystem.InputActionAsset.OnDestroy () (at ./Packages/com.unity.inputsystem/InputSystem/Actions/InputActionAsset.cs:919)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at D:/Gitrepo/unity/Modules/IMGUI/GUIUtility.cs:219)
  • I can move an action to its own map and then it dissapears with this error (steps to repro: Create new custom input actions asset with just one action -> move that action to its own map -> it dissapears. Does not seem to repro if the map has more than 1 action):
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.InputSystem.Editor.CopyPasteHelper.IsComposite (UnityEditor.SerializedProperty property) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:26)
UnityEngine.InputSystem.Editor.CopyPasteHelper.PasteBindingOrComposite (UnityEditor.SerializedProperty arrayProperty, System.String json, System.Int32 index, System.String actionName, System.Boolean createCompositeParts) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:263)
UnityEngine.InputSystem.Editor.CopyPasteHelper.PasteAction (UnityEditor.SerializedProperty arrayProperty, System.String jsonToInsert, System.Int32 indexToInsert) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:253)
UnityEngine.InputSystem.Editor.CopyPasteHelper.PasteBlocks (System.String transmission, System.Int32 indexToInsert, UnityEditor.SerializedProperty arrayToInsertInto) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:217)
UnityEngine.InputSystem.Editor.CopyPasteHelper.PasteItems (System.String copyBufferString, System.Int32[] indicesToInsert, UnityEditor.SerializedProperty arrayToInsertInto) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:206)
UnityEngine.InputSystem.Editor.CopyPasteHelper.PasteData (System.String copyBufferString, System.Int32[] indicesToInsert, UnityEditor.SerializedProperty arrayToInsertInto) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:194)
UnityEngine.InputSystem.Editor.CopyPasteHelper.PasteActionsFromClipboard (UnityEngine.InputSystem.Editor.InputActionsEditorState state, System.Boolean addLast, System.Int32 mapIndex) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:179)
UnityEngine.InputSystem.Editor.CopyPasteHelper.PasteActionsOrBindingsFromClipboard (UnityEngine.InputSystem.Editor.InputActionsEditorState state, System.Boolean addLast, System.Int32 mapIndex) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CopyPasteHelper.cs:164)
UnityEngine.InputSystem.Editor.Commands+<>c__DisplayClass12_0.<PasteActionIntoActionMap>b__0 (UnityEngine.InputSystem.Editor.InputActionsEditorState& state) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs:156)
UnityEngine.InputSystem.Editor.StateContainer.Dispatch (UnityEngine.InputSystem.Editor.Command command) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/StateContainer.cs:35)
UnityEngine.InputSystem.Editor.ViewBase`1[TViewState].Dispatch (UnityEngine.InputSystem.Editor.Command command) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ViewBase.cs:78)
UnityEngine.InputSystem.Editor.ActionMapsView.OnDroppedHandler (System.Int32 mapIndex) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionMapsView.cs:75)
UnityEngine.InputSystem.Editor.DropManipulator.OnDragPerformEvent (UnityEngine.UIElements.DragPerformEvent evt) (at ./Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/DropManipulator.cs:47)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) (at D:/Gitrepo/unity/Modules/UIElements/Core/Events/EventCallback.cs:64)
UnityEngine.UIElements.EventCallbackRegistry+DynamicCallbackList.Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target) (at D:/Gitrepo/unity/Modules/UIElements/Core/Events/EventCallbackRegistry.cs:228)
UnityEngine.UIElements.EventDispatchUtilities.HandleEventAcrossPropagationPath (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target, System.Boolean isCapturingTarget) (at D:/Gitrepo/unity/Modules/UIElements/Core/Events/EventDispatchUtilities.cs:150)
UnityEngine.UIElements.EventDispatchUtilities.DispatchToCapturingElementOrElementUnderPointer (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, System.Int32 pointerId, UnityEngine.Vector2 position) (at D:/Gitrepo/unity/Modules/UIElements/Core/Events/EventDispatchUtilities.cs:578)
UnityEngine.UIElements.MouseEventBase`1[T].Dispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at D:/Gitrepo/unity/Modules/UIElements/Core/Events/MouseEvents.cs:248)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at D:/Gitrepo/unity/Modules/UIElements/Core/EventDispatcher.cs:336)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at D:/Gitrepo/unity/Modules/UIElements/Core/EventDispatcher.cs:200)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at D:/Gitrepo/unity/Modules/UIElements/Core/Panel.cs:634)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at D:/Gitrepo/unity/Modules/UIElements/Core/UIElementsUtility.cs:511)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at D:/Gitrepo/unity/Modules/UIElements/Core/UIElementsUtility.cs:230)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at D:/Gitrepo/unity/Modules/UIElements/Core/UIElementsUtility.cs:76)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at D:/Gitrepo/unity/Modules/UIElements/Core/UIElementsUtility.cs:30)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at D:/Gitrepo/unity/Modules/IMGUI/GUIUtility.cs:219)

@ritamerkl
Copy link
Collaborator Author

I also wonder why we do not rely on DragEnter and DragExit anywhere since these kind of events are typically what are used to update drag icons and/or evaluate whether drag source and drag targets are a valid combination to e.g. discard or allow drop.

We need to use the Drag and Drop events that are used internally in UITK for the reorderable logic. This is because we rely on the reorderable and append custom (e.g. drag between lists, restricting) implementation.

@ritamerkl
Copy link
Collaborator Author

  • I can drop composite bindings into non composite actions (and vice versa) -> after dragging them they jump back to where they were. Expected: block symbol on mouse is shown and you can't drag them there at all

I left a comment in the code where to block/discard a drag, currently it's handled with a forced reload of the treeview (that's sometimes a bit delayed what explains the jumping element). I would suggest to open a ticket for this as it's just about visuals.

  • Undo naming is not user friendly shown as "Modified Actions Maps.Array..." or "Modified x# properties"
    Expected: "Moved Action/Binding x" does not need to go into specifics where it was moved, just has to be human readable of what action was done

I would suggest a ticket for this one as well as it's not very urgent neither.

@ritamerkl
Copy link
Collaborator Author

ritamerkl commented Feb 7, 2024

  • Unknown steps to error so far but got it when loading the ProjectWideActions test scene (ignore if cause not clear from error message alone):

not clear to me, looks like an problem with the asset itself....

  • I can move an action to its own map and then it dissapears with this error (steps to repro: Create new custom input actions asset with just one action -> move that action to its own map -> it dissapears. Does not seem to repro if the map has more than 1 action):

fixed in 2175b70, was actually reproducable on develop as well, seems we missed that somehow

@Pauliusd01

This comment was marked as outdated.

@Pauliusd01
Copy link
Collaborator

Pauliusd01 commented Feb 8, 2024

Unity_2024-02-08_14-09-54.mp4

Seems like adding new processors/interactions to an action is broken after reordering it. Probably a selection issue as deselecting and re-selecting it fixes it

Copy link
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

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

LGTM once bug with processors is fixed. Things checked can be found in the QA card: ISX-1692. Additional bugs filed for later: ISX-1871 and ISX-1872

@ritamerkl
Copy link
Collaborator Author

ritamerkl commented Feb 8, 2024

Seems like adding new processors/interactions to an action is broken after reordering it. Probably a selection issue as deselecting and re-selecting it fixes it

This is definitely a selection issue. I wonder if the changes on Håkans branch (continue with -> append the selection of the moved item) would fix this easy. Maybe worth checking after a merge.

@Pauliusd01
Copy link
Collaborator

Seems like adding new processors/interactions to an action is broken after reordering it. Probably a selection issue as deselecting and re-selecting it fixes it

This is definitely a selection issue. I wonder if the changes on Håkans branch (continue with -> append the selection of the moved item) would fix this easy. Maybe worth checking after a merge.

Ok added new bug - ISX-1873

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

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

LGTM, added some minor comments which are more food-for-thought.


void OnDroppedHandler(int mapIndex)
{
Dispatch(Commands.CutActionsOrBindings());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is likely fine but I would recommend when we do a sequence of commands like this that they are implemented as a single command instead but is the combination of the two underneath. Otherwise this would yield two Undo steps "Cut" and "Paste" which might be confusing for a Drop? Another aspect is that since dispatched, if CutActionsOrBindings() throws, the new state is not propagated and the Paste will execute on the previous state. I think I have seen this in more places so might be that we overlook all places at a later point for exception-safety and Undo convenience.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, I think there your implementation of Dispatch(..,continueWith) would be a great solution, I would wait until this is landed and make use of this.

@ritamerkl ritamerkl merged commit 6db0cc5 into develop Feb 14, 2024
@ritamerkl ritamerkl deleted the isx-1141-uitk-drag-and-drop branch February 14, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants