Search Unity

Unity UI Expanding Button In Grid Layout Group

Discussion in 'UGUI & TextMesh Pro' started by UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396, Feb 9, 2020.

  1. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152

    Anyone know how to make this sort of expanding button effect? I don't know how to position the anchor point dynamically so that it scales appropriately like that. My Parent object has a grid layout group.
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Grid Layout Group is designed to do layouts where every cell is always exactly the same size. It can't do this in any straightforward way.

    You could do something like that using a Horizontal Layout Group instead, by changing the element's min/preferred/flexible width (which could be done e.g. by using a Layout Element component on each child).

    You also could write your own script for laying things out exactly how you want them by directly manipulating their transforms.
     
  3. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    Thank you so much :)