예제 #1
0
파일: Menu.cs 프로젝트: jaycii27/seal-saver
        static public GameObject AddMassivePicker(MenuCommand command, string name, bool zoom, bool horizontal, bool noitem)
        {
            GameObject pickerRoot = MenuOptions.CreateUIElementRoot(name, command, MenuOptions.s_ImageGUIElementSize);

            GameObject columnList = new GameObject("ColumnList");

            GameObjectUtility.SetParentAndAlign(columnList, pickerRoot);

#if UNITY_5_4_UNDER
            columnList.AddComponent(horizontal ? typeof(VerticalLayoutGroup) : typeof(HorizontalLayoutGroup));
#else
            if (horizontal)
            {
                VerticalLayoutGroup group = columnList.AddComponent <VerticalLayoutGroup>();
                group.childControlWidth  = true;
                group.childControlHeight = true;
            }
            else
            {
                HorizontalLayoutGroup group = columnList.AddComponent <HorizontalLayoutGroup>();
                group.childControlWidth  = true;
                group.childControlHeight = true;
            }
#endif

            RectTransform rect = (RectTransform)columnList.transform;
            rect.anchorMin = Vector2.zero;
            rect.anchorMax = Vector2.one;
            rect.sizeDelta = new Vector2(-20, -20);

            MassivePickerScrollRect column = AddMassiveColumn(columnList, zoom, horizontal);

            GameObject glass = AddGlass(pickerRoot, zoom, horizontal);
            AddFrame(pickerRoot);

            if (!noitem)
            {
                GameObject itemSource = new GameObject("ItemSource");
                GameObjectUtility.SetParentAndAlign(itemSource, pickerRoot);

                Vector2 itemSize = horizontal ? new Vector2(15, 50) : new Vector2(50, 20);

                if (!zoom)
                {
                    itemSource.AddComponent <ExampleStringItem>();
                }
                else
                {
                    ExampleZoomStringItem item     = itemSource.AddComponent <ExampleZoomStringItem>();
                    GameObject            zoomItem = new GameObject("zoomItem");
                    GameObjectUtility.SetParentAndAlign(zoomItem, itemSource);
                    SetExampleMassiveItemText(zoomItem, true);
                    RectTransform zoomItemRect = zoomItem.GetComponent <RectTransform>();
                    zoomItemRect.sizeDelta  = itemSize;
                    zoomItemRect.localScale = Vector3.one * 1.2f;
                    item.zoomItem           = zoomItem.transform;
                }

                SetExampleMassiveItemText(itemSource);

                RectTransform itemRectTransform = itemSource.GetComponent <RectTransform>();
                itemRectTransform.sizeDelta = itemSize;
                itemRectTransform.SetSiblingIndex(zoom ? 2 : 1);

                column.deactiveItemOnAwake = true;
                column.itemSource          = itemSource;
                column.itemSize            = itemRectTransform.sizeDelta;
                column.itemCount           = 10;
            }

            if (zoom)
            {
                column.content.GetComponent <MassiveZoomPickerLayoutGroup>().zoomItemParent = glass.transform;
            }

            return(pickerRoot);
        }