Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

FlowLayoutGroup

Discussion in 'UGUI & TextMesh Pro' started by Simie, Feb 8, 2015.

  1. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    454
    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 :)
     
    brokenm, Nandorand, iivo_k and 2 others like this.
  2. Feaver1968

    Feaver1968

    Joined:
    Nov 16, 2014
    Posts:
    70
    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.
     
  3. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
  4. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    454
    Last edited: Feb 8, 2015
  5. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Good point, each file has attributions in it, I'll also look to include the credits in the front page as well!
     
    Simie likes this.
  6. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    V1.0.0.2 of the UI Extensions project released including the FlowLayoutGroup :D
     
    Simie likes this.
  7. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    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?
     
  8. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    454
    If you submit a pull request to SRF I could include it there, if you'd like.
     
  9. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    If you can let me know when it's updated @Simie and I'll pull the changes in to the UI Extensions Repo
     
  10. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    Done. I hope I broke nothing ;)
     
  11. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
  12. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    yeah, I know ;)
     
  13. ccklokwerks

    ccklokwerks

    Joined:
    Oct 21, 2014
    Posts:
    62
    This is just fantastic work. Thank you very much for making this available to us all!
     
  14. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    Quick question: Anyone up to make the flowLayoutGroup flexible so it can either do rows first or columns first?
     
    modernator24 likes this.
  15. jcuriel_glu

    jcuriel_glu

    Joined:
    May 26, 2017
    Posts:
    16
    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.

    FlowLayoutGroupCenter.jpg FlowLayoutGroupRight.jpg
     
    Last edited: Sep 20, 2018
    silentmaster likes this.
  16. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    166
    How to set column count?
     
  17. EdwinLyons

    EdwinLyons

    Joined:
    Oct 4, 2012
    Posts:
    82
    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
     
    PolyCrusher and MetaRolf like this.