public void CreateSetup()
        {
            var image = GetComponent <Image>();

            if (image != null)
            {
                image.enabled = false;
            }

            if (columns < 2)
            {
                columns = 2;
            }
            var columnParentRect = LayoutEditorUtilities.CreateHoritontalOrVertical(GetComponent <RectTransform>(), LayoutEditorUtilities.LayoutDirection.Horizontal, columns, 0.01f);

            columnParentRect.sizeDelta = new Vector2(-2 * LayoutPanel.borderSize, -6 * LayoutPanel.borderSize);
            var layoutGroup = columnParentRect.GetComponent <HorizontalLayoutGroup>();

            layoutGroup.AddOrGetComponent <LayoutHorizontalController>();

            layoutGroup.GetComponent <Image>().enabled = false;
            layoutGroup.spacing = LayoutPanel.borderSize * 3;
            var padding = layoutGroup.padding;

            padding.top         = LayoutPanel.borderSize * 2;
            padding.left        = LayoutPanel.borderSize;
            padding.bottom      = LayoutPanel.borderSize * 2;
            padding.right       = LayoutPanel.borderSize;
            layoutGroup.padding = padding;
            List <LayoutPanel> panels = new List <LayoutPanel>();

            for (int i = 0; i < columnParentRect.childCount; i++)
            {
                var thisColumn = columnParentRect.GetChild(i).gameObject;
                thisColumn.name = "Column " + i;
                AddColumnBorders(thisColumn, Color.Lerp(startColor, endColor, (float)i / columnParentRect.childCount));
                var border = thisColumn.AddComponent <LayoutBorderHide>();
                border.borderHideMode = hideCreatedBordersInHierarchy ? LayoutBorderHide.BorderHideMode.Hidden : LayoutBorderHide.BorderHideMode.Visible;
                thisColumn.GetComponent <Image>().enabled = false;
                if (i < columnParentRect.childCount - 1 || !leaveLastColumnEmpty)
                {
                    AddRandomChildren(thisColumn.gameObject, Random.Range(1, maxItemsTop), ref panels);
                }
                CreateSpacer(thisColumn.gameObject, flexWidth, flexWidth);
                if (i < columnParentRect.childCount - 1 || !leaveLastColumnEmpty)
                {
                    AddRandomChildren(thisColumn.gameObject, Random.Range(0, maxItemsBottom), ref panels);
                }
                thisColumn.AddOrGetComponent <LayoutColumn>();
            }

            SetColors(panels);
            UpdateBorders();
#if UNITY_EDITOR
            EditorApplication.delayCall += () => Selection.activeGameObject = gameObject;
#endif
        }
        public void CreateSetup()
        {
            if (columns < 2)
            {
                columns = 2;
            }
            var columnParentRect = LayoutEditorUtilities.CreateHoritontalOrVertical(GetComponent <RectTransform>(), LayoutEditorUtilities.LayoutDirection.Horizontal, columns, 0.01f);

            columnParentRect.sizeDelta = new Vector2(-2 * LayoutBorderDragger.borderSize, -6 * LayoutBorderDragger.borderSize);
            var layoutGroup = columnParentRect.GetComponent <HorizontalLayoutGroup>();

            layoutGroup.GetComponent <Image>().enabled = false;
            layoutGroup.spacing = LayoutBorderDragger.borderSize * 3;
            var padding = layoutGroup.padding;

            padding.top         = LayoutBorderDragger.borderSize * 2;
            padding.left        = LayoutBorderDragger.borderSize;
            padding.bottom      = LayoutBorderDragger.borderSize * 2;
            padding.right       = LayoutBorderDragger.borderSize;
            layoutGroup.padding = padding;
            List <LayoutPanel> panels = new List <LayoutPanel>();

            for (int i = 0; i < columnParentRect.childCount; i++)
            {
                var thisColumn = columnParentRect.GetChild(i).gameObject;
                thisColumn.name = "Column " + i;
                AddColumnBorders(thisColumn, Color.Lerp(startColor, endColor, (float)i / columnParentRect.childCount));
                thisColumn.AddComponent <LayoutBorderHide>();
                thisColumn.GetComponent <Image>().enabled = false;
                if (i < columnParentRect.childCount - 1 || !leaveLastColumnEmpty)
                {
                    AddRandomChildren(thisColumn.gameObject, Random.Range(1, maxItemsTop), ref panels);
                }
                CreateSpacer(thisColumn.gameObject, flexWidth, flexWidth);
                if (i < columnParentRect.childCount - 1 || !leaveLastColumnEmpty)
                {
                    AddRandomChildren(thisColumn.gameObject, Random.Range(0, maxItemsBottom), ref panels);
                }
                thisColumn.AddOrGetComponent <LayoutColumn>();
            }

            SetColors(panels);
            UpdateBorders();
        }
 public void CreateVerticalLayout()
 {
     LayoutEditorUtilities.CreateHoritontalOrVertical(GetComponent <RectTransform>(), LayoutEditorUtilities.LayoutDirection.Vertical, columns, 0.01f);
 }