Introducing UIDragDetectors [Studio-only Beta]

[Update] October 18, 2024

Hello Creators,

We are excited to announce the Studio-only beta release of UIDragDetectors, a new instance type designed to make interacting with UI elements easy! Similar to DragDetectors, UIDragDetectors are designed to make dragging behaviors and interactions easy for developers of all skill levels, but for 2D UI instead of 3D objects. They can be used to instantly inject 2D dragging behaviors under both ScreenGui and SurfaceGui instances, allowing you to make elements like sliders and spinners with little to no code.

This feature is currently enabled in Studio for all users, and we are targeting enabling it on client in a couple weeks’ time.

No scripting is required to make UI elements draggable; properties let you define how UIDragDetectors respond to interactions. However, scripting can unlock more advanced features, such as constraints, custom drag styles, or how your game responds when UI is dragged.


image2 image4

Examples of UIDragDetectors being used in SurfaceGuis to interact with 3D objects

How to use UIDragDetectors

To use UIDragDetectors, you will first need to enable the beta. To do that, go to File > Beta Features, then enable the UIDragDetectors Beta Feature.

To get started, add a UIDragDetector under any GuiObject instance, like a Frame. Hit Play and you will be able to interact with the Frame! In addition, you can move the Frame without hitting Play if there are no dragger tools (such as Select, Move, Scale, or Rotate) or plugins (such as the UIEditor) active.

image3

You can also customize UIDragDetectors through properties. Below you’ll find detailed documentation and a couple examples.

  1. DragStyle - choose between different kinds of dragging behaviors.
  2. ResponseStyle - choose whether to drag in Offset or Scale, and whether you want the computed drag to be applied to the UI element or not
  3. Axis/Movement Limits
  4. BoundingUI - designate another GuiBase2d or GuiObject instance to define the boundary of the drag
  5. ReferenceUIInstance - designate another GuiObject instance to change the reference frame of some drag behaviors and properties.

Additionally, event connections and methods can be used to customize UIDragDetector behavior and perform game logic.

For more information, read through our API Documentation and Guide.

Examples

Adding a basic UIDragDetector

It only takes a couple steps to create a draggable UI element with UIDragDetectors:

  1. Create a ScreenGui under StarterGui
  2. Add a GuiObject like a Frame as its child
  3. Add a UIDragDetector to the GuiObject
  4. Hit Play.
  5. Drag the GuiObject to move it in the screen plane.

You can also drag it in edit mode if you turn off the Dragger Tools.

Playing with DragStyle

DragStyle changes how you translate or rotate when you click and drag.

  1. Create a draggable UI element like you did in Example # 1.
  2. Change DragStyle of the UIDragDetector to TranslateLine.
  3. Hit Play.
  4. Drag the GuiObject to move it in the screen plane.
    • You will only be able to drag in the X-axis!
    • A property called DragAxis will show, which controls the axis in which the UIDragDetector drags in for the TranslateLine DragStyle.

Try playing with the Rotate DragStyle, too! For the Scriptable DragStyle, refer to the API documentation and Guide for details on how it works.

Try it out in our TestWorld

You can find all of the demos in the GIFs above, and many others, in our UIDragDetector TestWorld that is free to download, inspect, alter, copy, and reuse as you like! Click here, click ‘…’ near the title, then Edit to open them in Roblox Studio, then File → Download to save your own copy.

The world consists of both ScreenGui and SurfaceGui examples, showing you how to take advantage of all the properties and scripting options.

  • To interact with the ScreenGui examples, press Play and navigate to examples through the menu on the right.
    • You can change the Enabled property on the corresponding ScreenGui instances to test them out in Edit mode!
  • For the SurfaceGui examples, press Play and walk over to the examples to interact with them. It is possible to drag these elements in edit mode, but relevant scripts will not run. You can also copy the contents of the SurfaceGui examples onto a ScreenGui to see them in the screen plane– they will work just the same.

Check it out in UIDragDetectors Testing Examples.

Known issues

Since this is still in beta, you may run into some issues when working with UIDragDetectors. Here are some common bugs that we are currently in the process of squashing:

  • Bounding issues may exist with UIDragDetectors that have a DragStyle of Rotate, a ReferenceUIInstance set, and a rotated BoundingUI set.
  • Changing the DragRotation property of a UIDragDetector with a defined ReferenceUIInstance performs a relative rotation, not a rotation to the absolute value; so if the current value is 9 and the new value is 10, the result will be a rotation of 19, although it should be 10.
  • Some GuiObject events, such as MouseEnter and MouseLeave, won’t fire properly during a UIDragDetector drag.
  • The UIDragDetector hover cursor may not change correctly when moving over overlapping GuiObjects with different UIDragDetectors.

What’s next?

There are a couple features that we’d like to add before exiting beta! These include, but are not limited to:

  • Having a clearly defined behavior for dragging GuiObjects influenced by UILayouts
  • Possible support for BillboardGui

We’ll update you once these features are available in the beta.


Finally, I’d like to thank @PrinceTybalt, @PolarPorcupine, @rbx_dert, @IgnisRBX, @bluff_006, @frecklesnspectacles, members of the UI team, our QA team, and everyone throughout Roblox that helped shape and bring this feature to work in the Roblox ecosystem.
Thank you!

630 Likes

This topic was automatically opened after 10 minutes.

Well, one possible use case is to make it possible for mobile players to drag and drop the UI themselves to change the UI size through this feature, so that we don’t have to do the adaptation (just kidding)

84 Likes

Weeeeeee!!

This update is awesome, I can’t wait to use this!

97 Likes

You’re making all my hard work obsolete :frowning:
Untitled video - Made with Clipchamp

Nevertheless, I am sure this will save people in the future from the same fate I had of long hours trying to work this out. Great work.

187 Likes

Been waiting for this for a long time, this is going to speed up progress so much!

65 Likes

It’s so cool I’m wait full release

52 Likes

This is amazing! I can’t wait for more updates.

47 Likes

Finally!! Crazy how long I’ve been using workarounds to make sliders :sob:

Thanks to everybody who worked on this! Will be super useful going forward.

63 Likes

This is an amazing update, I hope if you would be able to add fixed points to the dragger therefore it can be easy to navigate.

e.g. add a fixed point (0.5) to a sound slider

However, This is pretty cool, Can’t wait for more fascinating updates!

47 Likes

Ayy! Finally I don’t need to suffer to make a slider work!

45 Likes

You mean I don’t have to code these myself anymore? Awesome!! Would love to see some more advanced options like snapping behavior as well!
discrete

106 Likes

Could you elaborate on that use case? I’m not sure if I can quite visualize what a fixed point that you mention would be

Edit: Relevant reply!

46 Likes

LETS GOOOO!!! RAAAAAHHH

Thank you SOOOO much Roblox! This will make so many of my workflows easier!

41 Likes

You can add custom constraints to somewhat easily add snapping behavior! Our Guide showcases an example of gridded dragging, which is essentially 2D snapping (instead of 1D).

54 Likes

A few use cases off the top of my head:

  • Shifting gears in a car.
  • Remixing music as a DJ.
  • 2D platformer game on a handheld device for your avatar.
  • Puzzles like bypassing security systems.
  • Disarming a bomb by pulling wires.
  • Targeting system for artillery.
  • Painting on a SurfaceGui.
  • Navigating routes on a GPS map.
  • Joysticks for a drone control app.
  • Transferring items from your inventory between storage crates.
  • Field of view slider.
  • Dimmer switch for lights.
  • (List continues because I cannot write these ideas down fast enough!)
62 Likes

Will this work on a controller too?

38 Likes

It should work with all inputs-- please let us know if there are issues, and we’ll get to debugging them.

At the moment, it is a Studio-Only feature, but it will be rolled out to all clients in the near future.

38 Likes

Awesome feature, definitely have a few use-cases for this when it comes to the client.

29 Likes

This is gonna be so useful thank you for releasing this

21 Likes