I have a scrolling frame UI object, and inside of it I have several button objects that are added when needed by script during game.
However, when I expand the canvas size to hold these, and to get the scroll bar to show up, all the buttons resize based on the canvas size, rather than the size of the visible viewport of the scrolling frame.
Is there any way to get the buttons to resize based on the frame size, not the canvas size?
Yeah, im using percents. I mean I can always use pixels and just calculate it each time the menu is opened, in case for some reason someone’s screen has changed size. But I thought it might be some setting or something that I was missing that could just do that on the auto.
Hi, this happened to me many times. I used pixels for the buttons, and to avoid any display problem when the screen size changes, I just add (may not be that efficient) 2 lines like:
local screengui = your screengui;
local defSize = screengui.AbsoluteSize.Y; --default screengui size
local buttonSizes = UDim2.new(idk,idk,idk,50); --for example
screengui.Changed:Connect(function(p)
if p=='AbsoluteSize' then
buttonsizes=(50*screengui.AbsoluteSize.Y)/defSize;
end
end)
for i,v in pairs(yourbuttonshere) do
v.size=udim2.new(stuff,stuff,stuff,buttonsizes)
end
To get a similar effect to Scale, you can get the Scale value at the beginning for the X and Y Sizes of the GuiObject and then resize the GuiObject to:
Bind a connection to GuiObject.Parent:GetPropertyChangedSIgnal(“AbsoluteSize”) and then resize the GuiObject whenever this happens and It should be fine.