public static void ShowWindow(ScrollGallery scrollGallery)
        {
            var window = GetWindow <ScrollGalleryAutoArrangeWindow>("ScrollGalleryAutoArrangeWindow");

            window.scrollGallery = scrollGallery;
            var r = window.position;

            r.width         = 500;
            r.x             = Screen.currentResolution.width / 2 - r.width / 2;
            r.y             = Screen.currentResolution.height / 2 - r.height / 2;
            window.position = r;
        }
        private void OnGUI()
        {
            this.scrollGallery = EditorGUILayout.ObjectField("当前ScrollSystem:", this.scrollGallery, typeof(ScrollGallery), true) as ScrollGallery;
            if (this.scrollGallery == null)
            {
                return;
            }
            GUILayout.Label("当前滚动方向:" + ((this.scrollGallery.Direction == ScrollGallery.ScrollDirection.Vertical) ? "垂直" : "水平"));
            GUILayout.BeginHorizontal();
            this.spacing = Mathf.Max(0, EditorGUILayout.FloatField("间隔:", this.spacing));
            if (GUILayout.Button("自动排列"))
            {
                AutoArrangeBySpacing();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("对齐:");
            if (this.scrollGallery.Direction == ScrollGallery.ScrollDirection.Vertical)
            {
                if (GUILayout.Button("左对齐"))
                {
                    AutoArrangeByFitLeft();
                }
                if (GUILayout.Button("中对齐"))
                {
                    AutoArrangeByFitCenter();
                }
                if (GUILayout.Button("右对齐"))
                {
                    AutoArrangeByFitRight();
                }
            }
            else
            {
                if (GUILayout.Button("上对齐"))
                {
                    AutoArrangeByFitUp();
                }
                if (GUILayout.Button("中对齐"))
                {
                    AutoArrangeByFitCenter();
                }
                if (GUILayout.Button("下对齐"))
                {
                    AutoArrangeByFitDown();
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Scale Delta:");
            this.scaleDelta = EditorGUILayout.Vector2Field("", this.scaleDelta);
            if (GUILayout.Button("等差调整"))
            {
                DoScale();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Width&Height Delta:");
            this.widthAndHeightDelta = EditorGUILayout.Vector2Field("", this.widthAndHeightDelta);
            if (GUILayout.Button("等差调整"))
            {
                DoWidthAndHeight();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            this.maskTransform = EditorGUILayout.ObjectField("Mask:", this.maskTransform, typeof(RectTransform), true) as RectTransform;
            if (this.maskTransform != null && GUILayout.Button("匹配大小和位置"))
            {
                FitMask();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(20);
            if (GUILayout.Button("创建父物体RectMask,进行裁切"))
            {
                var origin = scrollGallery.transform as RectTransform;
                var temp   = new GameObject("RectMask", typeof(RectTransform)).transform as RectTransform;
                temp.gameObject.AddComponent <UnityEngine.UI.RectMask2D>();
                temp.transform.SetParent(scrollGallery.transform.parent);

                temp.anchorMin            = origin.anchorMin;
                temp.anchorMax            = origin.anchorMax;
                temp.anchoredPosition     = origin.anchoredPosition;
                temp.sizeDelta            = origin.sizeDelta;
                temp.transform.localScale = origin.transform.localScale;
                origin.transform.SetParent(temp);
            }
        }