Introducing UIDragDetectors [Studio-only Beta]

The day has come! (Not quite since this is in beta, but the sentiment is here for sure). I look forward to using this.

1 Like

How did you do that? Iā€™m currently trying to make something like that, but cant make anything move if its sibling is any of the UILayout instances (grid, list, table). Pulling my hair because itā€™s just not dragging at all.

1 Like

This will be amazing to use in VR games!! not saying i donā€™t have one on the very short horizon!

1 Like

omg :DDDDDD thanks ROBLOX!!! :DDDDDDDDDDDDDDDDDDDDDDDDD
probably one of the best UI updates ever because I remember the Draggable bool value was removed now I am so happy itā€™s back!!!

good job ROBLOX!!! :D:D:D:D::D:DDD :DDDDDDDDDDDD

and yea keep up good updates. :)

2 Likes

First, what I did is I made an array that defines OccupiedTiles. This can be done using a for i Loop for the X and the Y axis. (also worth nothing this isnā€™t using any UI ordering instances such as UIListLayout, UIGridLayout, etc.)

local Grid = {}
local xAmount: number = 2
local yAmount: number = 2

for x = 1, xAmount do
   for y = 1, yAmount do
      --this is where you would want to check Tile size, how big an object is, etc.
      table.insert(Grid, Vector2.new(x, y))
   end
end

On DragStart I save the previous position of the object (this could really be done in many ways, but this is what I did to test out the UIDragDetector).

Then on DragEnd I create a Position that snaps to the nearest tile. However, before applying the changes to it, I check if the tiles itā€™s trying to go to are unoccupied. If the tiles are unoccupied then it will be placed to the given position, otherwise it will just return to its previous position.

Also worth nothing as the original post says, a current issue is that UIDragDetectors seem to be blocking some common UI events from firing, such as MouseButton1Click.

Also I added a few more functionalities with it while testing further so hereā€™s an updated version of it.

5 Likes

I have some problems with the frame resizing it doesnā€™t work in my plugin what should cuz it is in studio but the drag cursor disappear when you try to drag and not resize @DeFactoCepti @PrinceTybalt

Canā€™t wait for this to release itā€™s amazing

I wonder if its possible to make UI resizing easier with this

3 Likes

Slightly off-topic, but this made me realize that TextButtons and such should also have properties for cursor images.

5 Likes

currently I manually move ui elements around by detecting mouse button input and moving the ui over to the mouse position. would it be better or worse to use this new object in the name of performance?

1 Like

They are currently not supported, but our current plan is for UIDragDetectors to swap the LayoutOrder when dragged & dropped over another GuiObject thatā€™s affected by the same Layout-- this behavior should be togglable.

For Layouts that donā€™t use LayoutOrder, you would need to implement a custom behavior.

4 Likes

Iā€™m guessing this is the SurfaceGui contents ported over to a ScreenGui, adding the UIScale?

I will look into this :slight_smile: thank you!

4 Likes

I will look into this! Thank you for the report

3 Likes

We will be replying to this thread and edit the title & contents when itā€™s live on Client!

3 Likes

Thatā€™s interesting-- havenā€™t run into that myself personally.

Do you have a .rbxm of the frame / screenGui youā€™re using that reproduces this consistently? Iā€™ll try to figure out why that is happening.

2 Likes

The black circle has been reported-- we will fix it!

The Test Place UI wasnā€™t quite designed with the mobile in mind, and Iā€™ll try to make it better.

Regarding the resizing-- the behavior is done through lua script responses in the drag response events, and you can find the corresponding model in the test place with the name ā€œOffset Scale And Resizeā€.

3 Likes

This is great! Another great tool to UIs to make creating them easy

ā€¦now when will we stop having to script the AutomaticCanvasSize property :sweat_smile::sweat_smile: AutomaticCanvasSize should take into account padding

2 Likes

Thank you for this new feature, you now do not have to implement your system own system to achieve the same result, and is beginner-friendly.

2 Likes

You could do two things:

  1. Create a smaller parent that takes up the area that you want to drag, and have the UIDragDetector parented by that.
  2. Set the ResponseStyle to custom (For this case, CustomOffset is probably the one you want). On DragStart, store the position of the UI you want to move. On DragContinue, set the position of the UI you want to move as its initial position + the DragUDim2 of the UIDragDetector youā€™re using.

Constraint functions could work for this, too, but it would be doing the same thing as #2, and harder to set up.

Let me know if that works for you!

Edit: I suppose another hack could be that if your input on DragStart isnā€™t within a certain area (calculated by X/Y, over some Gui, etc), you could stop the drag by setting Enabled to false, then immediately re-enable for further drags. Thatā€™s not a pretty solution, though

1 Like

The cursor issue is known! A fix has been made & will be applied in two weeks.

4 Likes

There are known issues with cursors at the moment-- a fix should be incoming.

As for resizing, itā€™s expected to not work in edit mode, as itā€™s done by scripting on the events. It would only work in play mode.

1 Like