I couldn’t spot any obvious problems with the Lua scripts that the draggable element and drop target use. Here is a screenshot of the level:
After dropping the draggable, the original location is repopulated with the draggable and a copy of the draggable minus a few details is placed offset of the drop target. The offset is related to the drag length somehow and there is some additional offset being applied based on distance from the center of screen.
Any help would be appreciated!
In the ‘On Drag Start’ method of Draggable, I thought there might be an issue when self.clonedElement is assigned. Excerpt from DraggableCrossCanvasElement.lua:
if (self.dragCanvas:IsValid()) then -- clone the original draggable making it a child of the root element on the new canvas self.clonedElement = UiCanvasBus.Event.CloneElement(self.dragCanvas, self.entityId, EntityId(), EntityId()) if (self.clonedElement:IsValid()) then -- set the new cloned draggable element to act as a proxy for the original element UiDraggableBus.Event.SetAsProxy(self.clonedElement, self.entityId, position) -- hide the original element by reparenting it and disabling it so that we can drop -- the proxy at the original location if we want to self.originalParent = UiElementBus.Event.GetParent(self.entityId) UiElementBus.Event.Reparent(self.entityId, EntityId(), EntityId()) UiElementBus.Event.SetIsEnabled(self.entityId, false) end end
I’ve migrated this to SC, changing the parameters of UiCanvasBus.Event.CloneElement():
Note: In the Clone Element node (entity not found) takes the place of EntityId() in Lua.
If I change the Source to Original Parent and the ParentID to Drag Canvas as described in the comment on the graph, the level behaves differently. Draggables are no longer left in their old positions and they are set to the correct new positions without any offset problems, with all the images intact. However, the draggable isn’t visible during the drag and valid/invalid states are not shown on drop targets that are hovered over.