Tested it and it seems to work well. Thank you for sharing this.
A few suggestions for expanding upon this would be to be able to define frames as ‘Drop Zones’. You could then have different events that trigger when you have dragged something over a Drop Zone or when you ‘drop’ something into a Drop Zone. This could be useful when you want an inventory system and drag items to specific equipment slots, like boots, helmet, weapon etc.
Useful events could also be things like Drag started / ended so you could hook into that and in this example highlight the correct slot the item is supposed to go into.
These things can of course be used beyond just an inventory system.
Edit: will buttons for the resizing/moving be added soon?
Edit 2: having corner buttons (making the x and y both change at the same time) would be nice.
Edit 3: IK this prob would be complicated but: having a minimum/maximum size for resize.
Buttons for resizing/moving will be added soon hopefully.
Corner buttons are a plan, so they will come soon too.
Minimum/max size is something that I’d like so that will definitely come soon.
local TransformGui = require(game.ReplicatedStorage:FindFirstChild("TransformGui"))
local Frame = script.Parent:WaitForChild("Frame")
local Frame1 = script.Parent:WaitForChild("Frame1")
local transformableGui = TransformGui.new(script.Parent.Frame, true)
transformableGui:makeDraggable()
transformableGui:makeResizeable()
local transformableGui1 = TransformGui.new(Frame1, true)
transformableGui1:makeDraggable()
function CheckOverlap()
local a1 = Frame.AbsolutePosition.Y
local b1 = Frame1.AbsolutePosition.Y
local a2 = a1 + Frame1.AbsoluteSize.Y
local b2 = b1 + Frame1.AbsoluteSize.Y
if (b1 <= a1 and b2 <= a1) or (a2 <= b1 and a2 <= b2) then
return false
else
return true
end
end
function Snap()
if CheckOverlap() == true then
transformableGui1.Position = transformableGui.Position
end
end
transformableGui1.OnDragEnded:Connect(Snap)
Looks really nice. I would suggest for players to be able to resize UI elements by the corners like if they click on the bottom/top corners it would size on the X and Y-axis.