コード例 #1
0
        public MorphSelectUI(ExpressionCreator script)
        {
            this.script = script;

            Color color = GetNextColor();

            groupString = new JSONStorableStringChooser("group", script.morphGroupMap.Keys.ToList(), "", "Morph Group", (string groupPopupName) =>
            {
                string groupName = script.morphGroupMap[groupPopupName];
                GenerateDAZMorphsControlUI morphControl = script.GetMorphControl();
                List <string> acceptedMorphs            = new List <string>();
                script.GetMorphControl().GetMorphDisplayNames().ForEach((name) =>
                {
                    DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                    if (morph.region == groupName)
                    {
                        acceptedMorphs.Add(morph.displayName);
                    }
                });

                if (selectedMorph != null)
                {
                    morphValue.SetVal(selectedMorph.startValue);
                    selectedMorph = null;
                }

                List <string> existing = script.GetExistingMorphNames();

                morphString.choices = acceptedMorphs.ToList().Where((name) =>
                {
                    return(existing.Contains(name) == false);
                }).ToList();
                morphString.SetVal(morphString.choices[0]);

                morphPopup.gameObject.SetActive(true);
            });

            groupPopup        = script.CreatePopup(groupString, true);
            groupString.popup = groupPopup.popup;

            morphString = new JSONStorableStringChooser("morph", new List <string>(), "", "Morph", (string morphName) =>
            {
                GenerateDAZMorphsControlUI morphControl = script.GetMorphControl();
                DAZMorph morph = morphControl.GetMorphByDisplayName(morphName);
                if (morph == null)
                {
                    return;
                }

                if (selectedMorph != null)
                {
                    script.OnMorphRemoved(selectedMorph);

                    morphValue.SetVal(selectedMorph.startValue);
                    selectedMorph = null;
                }

                selectedMorph  = morph;
                morphValue.min = morph.min;
                morphValue.max = morph.max;
                morphValue.SetVal(morph.startValue);
                morphValue.defaultVal = morphValue.defaultVal;

                removeButton.label = "Remove " + selectedMorph.displayName;
                morphSlider.label  = selectedMorph.displayName;

                script.OnMorphSelected(selectedMorph);

                morphSlider.gameObject.SetActive(true);
                groupPopup.gameObject.SetActive(false);
            });
            morphPopup        = script.CreateScrollablePopup(morphString, true);
            morphString.popup = morphPopup.popup;

            morphPopup.gameObject.SetActive(false);

            morphValue = new JSONStorableFloat("morphValue", 0, (float value) =>
            {
                if (selectedMorph == null)
                {
                    return;
                }

                selectedMorph.SetValue(value);

                script.OnMorphValueChanged(selectedMorph, value);
            }, 0, 1, false, true);

            morphSlider       = script.CreateSlider(morphValue, true);
            morphValue.slider = morphSlider.slider;
            morphSlider.gameObject.SetActive(false);
            morphSlider.quickButtonsEnabled = false;

            removeButton = script.CreateButton("Remove Morph", true);
            removeButton.button.onClick.AddListener(() =>
            {
                Remove();
            });

            spacer = script.CreateSpacer(true);
        }