public void PositionContent(FolderContent content, int atIndex)
{
// since I'm placing the contents in a 1 dimensional list, I have to get the 2 dimensional index of the content to position it
// nContentsToFit is how many contents fits inside the current folder in terms of rows / cols (ex 4x4) (related to the dimensions of the folder's background)
// an example of the offset: the 6th content has an index of 5 (in 1d), now in a 4x4 folder its 2d index is (1,1) (2nd row, 2nd col)
// Index2D is just a struct holding two integers, much like a V2 but for ints instead of floats
var offset
= new Index2D
(atIndex
/ nContentsToFit
.col, atIndex
% nContentsToFit
.j);
// ContentWidth is the width of the folder/file's background -- which is the problem
float x = offset.col * ContentWidth + offset.col * spaceBetweenContents;
float y = offset.row * ContentHeight + offset.row * spaceBetweenContents;
var trans = content.cachedTransform;
trans.position = topLeft.position; // an empty gameObject to start positioning the contents from
var screenpos = guiCamera.WorldToScreenPoint(trans.position);
screenpos.x += x;
screenpos.y -= y;
trans.position = guiCamera.ScreenToWorldPoint(screenpos);
}