Scrolling frame canvas size based on frame size and contents

tl;dr if the scrolling frame isn’t big enough to fit all of the contents of it on the screen, I need to expand the canvas size so the user can scroll through all of the available options.

What I am trying to do is set the canvas size of a scrolling frame based on the size of the contents inside and the size of the frame (on the x axis).
My game must use scale as it needs to be able to fit on any screen (whether it be 1:1 or 2:1 aspect ratio or 720p or 2160p). Being able to run on any computer is a very important for my game as their may be a small player base for it and I want those who do play it to enjoy it as much as possible.

The distance between objects in the frame is relatively the same. This is done by having the first one set at the start position of the frame and the subsequent objects are children of the previous. This is so the scale doesn’t squash them all together.

It looks like so:
https://streamable.com/iw5l1

I made the scrolling bar slightly visible so you can see it change size in this (normally it would not be visible).

The scrolling frame has the following properties:
image
image
The contents inside are the following sizes:
image
image
image
(and every subsequent object inside has the same properties as the third)
image

All I know is that I need to use absolute size of the scrolling frame to probably calculate a relative scale by doing something like loadouts.AbsoluteSize.X/loadouts.AbsoluteSize.Y and then use the size of the contents to somehow calculate the canvas size but I have absolutely no idea.
I don’t have a problem with using offset in the canvas size, as long as it works on all resolutions.

If this is all a bit confusing you can download the place here and have a look for yourself:
https://drive.google.com/file/d/1xBnhaCefmRHsXvtJIqNnPF_Djjjb7d6T/view?usp=sharing
*Make sure you read the tldr
Thanks for the help!

2 Likes

This question has already been asked and answered:

3 Likes

It’s v. late for me right now and I’m about to go to sleep but I’ll check this out in the morning. Didn’t realise it had already been answered (there are wayyyy to many ways to phrase it) but thank you! :slight_smile:

1 Like