Fitting multiple 'inventory tabs' in a scrolling frame

I’m currently working on a weighted inventory system. The coding is relatively simple, but my problem comes at organizing the different inventory tabs.

Every inventory tab is organized into its own section, similar to a game called Aftermath. Aka, a vest may have a 3 by 4 slot, a backpack may have a 5 by 6 slot, etc etc. Now,. fitting these tabs into a scrolling frame is tricky.

image
^ How a “Tab” Looks


^ where tabs need to fit

image
^ example of aftermath fitting tabs and organizing them perfectly.

This obviously needs some math to it but it has been pretty tricky for me, any solutions or guidepoints?

1 Like

Anyone know anything on this potentially? still struggling.