FlowLayoutGroup

Hi all,

When developing my debug panel tool (SRDebugger) I had need of a FlowLayoutGroup which could handle oddly sized objects and resizing correctly. I’ve published it in my open source library SRF, in case anyone else has need of something similar.

Here is a video to demonstrate how it behaves:

It supports all child alignments, and ContentSizeFitter. If ChildForceExpandWidth is selected then items will be stretched to fill a row, and if ChildForceExpandHeight is selected then all items in a row will be stretched to be the same height as the largest item.

Link to the implementation (FlowLayoutGroup.cs)

Hopefully someone else finds this useful :slight_smile:

6 Likes

Thanks for sharing this. This is exactly what I needed for my interface. I struggled with trying to do something similar before they open sourced the ui but it was the fails.

Great stuff, If you are ok with it, I’ll add this to the UI Extensions bitbucket repo @Simie :
https://bitbucket.org/ddreaper/unity-ui-extensions

Hi @SimonDarksideJ , I’m happy to have it included in your UI Extensions repo. Could you attribute it to Stompy Robot LTD and link to the github page in FlowLayoutGroup.cs, and the notes column in the readme?

Good point, each file has attributions in it, I’ll also look to include the credits in the front page as well!

1 Like

V1.0.0.2 of the UI Extensions project released including the FlowLayoutGroup :smile:

1 Like

I’ve done some changes to this - I’ve added separate X and Y spacing and an option to automatically and equally stretch the spacing, not the child width. Anyone interested?

If you submit a pull request to SRF I could include it there, if you’d like.

If you can let me know when it’s updated @Simie and I’ll pull the changes in to the UI Extensions Repo

Done. I hope I broke nothing :wink:

Famous last words engraved on every developers tombstone @Democide :smile:

yeah, I know :wink:

This is just fantastic work. Thank you very much for making this available to us all!

Quick question: Anyone up to make the flowLayoutGroup flexible so it can either do rows first or columns first?

1 Like

I’m running into an issue where if you have one element on the grid on its own row, using and of the Center or Right options will cause the element to not be positioned as expected. Any ideas what would need to change in this script so they aligned themselves properly? Seems to have something to do with the Spacing on X. It should be noted that it having more than one item seems to work just fine.

1 Like

How to set column count?

8 years late, but here’s a version that lays things out in columns in rather than rows, useful for horizontal lists with items of different heights:

https://gist.github.com/eAi/c4c7fa9c35b8cb34d25f730bf70eaaf4

2 Likes