Home > Enterprise >  Unity Grid Layout Group Reverse Arrangement
Unity Grid Layout Group Reverse Arrangement

Time:05-12

How can I reverse the arrangement of a grid layout group? It is really easy to do it with vertical&horizontal layout groups cuz they literally have a toggle.

Grid Layout Group

Horizontal Layout Group

CodePudding user response:

You can change the arrangement of the items by changing the Start Corner.

Upper Left Left To Right, Top To Bottom

Upper Right Right To Left, Top To Bottom

Lower Left Left To Right, Bottom To Top

Lower Right Right To Left, Bottom To Top

CodePudding user response:

    public void changeSort(bool setfirst)
{
    var items = GameObject.FindGameObjectsWithTag("items");

    foreach (GameObject b in items)
    {
        if (setfirst)
        {
            b.GetComponent<RectTransform>().SetAsFirstSibling();
        }
        else
        {
            b.GetComponent<RectTransform>().SetAsLastSibling();
        }
    }
}
  • Related