I am trying to figure out how I can create a UI layout like so
I can’t use UIListLayout and was thinking I need to do some sort of radial thing to get the arch on the buttons. It’d need to scale based on the amount of elements too. So if you had like 50, they can’t go off screen
My attempt yielded this monstrocity
local HUD = script.Parent
local CardContainer = HUD:WaitForChild("CardContainer")
local Cards = {}
for i = 1, 7 do
local NewCard = script.Card:Clone()
NewCard.Parent = CardContainer
table.insert(Cards, NewCard)
--task.wait(0.5)
end
local radius = 0.5
local angularSpacingDegrees = 45
local sweep = (#Cards - 1) * angularSpacingDegrees
local startingAngle = -90 - (sweep / 2)
for i, button in pairs(Cards) do
local degree = startingAngle + ((i - 1) * angularSpacingDegrees)
local pos = UDim2.new(
0.5 + (radius * math.cos(math.rad(degree))), 0,
0.5 + (radius * math.sin(math.rad(degree))), 0
)
button.Position = pos
end
Divide the amount of pixels you want it to be by the amount of cards you want(x), then you can figure out the spacing, Then just clone it and set the spacing by x. For rotation, it’s the same on all these cards. Just check if the position is on one side, if it is then set it to - whatever.
Well get the spacing between each card, then space each card out. For example 10 cards, each card takes up 1/10 scale space or px/10 offset space. Once that’s done, loop through each card and offset it based on it’s index, with the middle being the highest.
Slightly unsure on the math of positioning them. I have a CardContainer that’s 0.8 on the X. Card inside aren’t being positioned centrally tho. CardContainer is the semi transparent black frame that’s selected
local ScreenSize = CardContainer.AbsoluteSize.X
local CardSize = CardContainer.AbsoluteSize.Y
while true do
local TotalCards = #Cards
for i = 1, TotalCards do
local Card = CardContainer:FindFirstChild(i)
Card.Position = UDim2.fromScale((i / TotalCards), 0.5)
Card.ImageLabel.ZIndex = i
end
task.wait()
break
end
And as cards get removed, the scaling becomes worse, and everything kinda moves to one side, like 4 cards