示例#1
0
        public MorphSearch(BaseModule baseModule)
        {
            UI        ui       = baseModule.ui;
            Transform moduleUI = baseModule.moduleUI;
            Atom      atom     = baseModule.atom;

            searchBox = ui.CreateTextInput("Search For Morph", 800, 100, moduleUI);
            searchBox.transform.localPosition = new Vector3(0, -110, 0);

            paginationSlider = ui.CreateSlider("Page", 930, 80, true, moduleUI);
            paginationSlider.transform.localPosition = new Vector3(0, -200, 0);

            paginationValue = new JSONStorableFloat("Page", 0, (float value) =>
            {
            }, 0, 10, true, true);
            paginationSlider.valueFormat = "n0";
            paginationValue.slider       = paginationSlider.slider;

            paginationSlider.gameObject.SetActive(false);

            GridLayoutGroup layout = ui.CreateGridLayout(1200, 800, moduleUI);

            layout.transform.localPosition = new Vector3(0, -1010, 0);
            layout.constraintCount         = 3;
            layout.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
            layout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            layout.cellSize = new Vector2(400, 80);

            for (int i = 0; i < MAX_MORPHS_PER_PAGE - 1; i++)
            {
                UIDynamicSlider slider = ui.CreateMorphSlider("Slider " + i, 400, 80, moduleUI);
                slider.transform.SetParent(layout.transform, false);

                morphSliders.Add(slider);
                slider.gameObject.SetActive(false);
            }


            DAZCharacterSelector personGeometry = atom.GetStorableByID("geometry") as DAZCharacterSelector;

            morphControl = personGeometry.morphsControlUI;

            regions = new HashSet <string>();
            morphControl.GetMorphDisplayNames().ForEach((name) =>
            {
                DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                regions.Add(morph.region);
            });

            morphNames = morphControl.GetMorphDisplayNames();

            searchBox.onValueChanged.AddListener(UpdateSearch);

            UIDynamicButton clearButton = ui.CreateButton("Clear", 120, 100, moduleUI);

            clearButton.transform.localPosition = new Vector3(810, -110, 0);
            clearButton.button.onClick.AddListener(() =>
            {
                searchBox.text = "";
                ClearSearch();
            });

            UIDynamicButton sortButton = ui.CreateButton("Sorted ByName", 60, 100, moduleUI);

            sortButton.transform.localPosition = new Vector3(1035, -110, 0);
            sortButton.button.onClick.AddListener(() =>
            {
                switchSort         = !switchSort;
                string storeSearch = searchBox.text;
                searchBox.text     = "";
                if (switchSort)
                {
                    sortButton.label = "Sorted ByValue";
                }
                else
                {
                    sortButton.label = "Sorted ByName";
                }
                searchBox.text = storeSearch;
            });

            VerticalLayoutGroup commonTermsGroup = ui.CreateVerticalLayout(220, 0, moduleUI);

            commonTermsGroup.transform.localPosition = new Vector3(-230, -200, 0);
            commonTermsGroup.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            commonTermsGroup.childAlignment = TextAnchor.UpperLeft;


            for (int i = 0; i < MAX_TERMS; i++)
            {
                UIDynamicButton termButton = ui.CreateButton("Term", 220, 40, moduleUI);
                termButton.transform.SetParent(commonTermsGroup.transform, false);
                termButtons.Add(termButton);
                UI.ColorButton(termButton, Color.white, new Color(0.3f, 0.4f, 0.6f));

                termButton.gameObject.SetActive(false);

                ContentSizeFitter csf = termButton.gameObject.AddComponent <ContentSizeFitter>();
                csf.verticalFit = ContentSizeFitter.FitMode.MinSize;
            }

            //Debug.Log("----------------------------");
            //UIDynamicSlider testSlider = ui.CreateMorphSlider("test");
            //ui.DebugDeeper(testSlider.transform);
        }