public override void Init()
        {
            try
            {
                TitleUITextField();

                color = new JSONStorableColor("Color", HSVColorPicker.RGBToHSV(1f, 1f, 1f), _ => SyncMats());
                RegisterColor(color);
                CreateColorPicker(color, true);
                FloatSlider(ref alpha, "Color Alpha", 1,
                            _ => { SyncMats(); }, 0, 2, true);

                renderOriginal = new JSONStorableBool("Render Original Material", true);
                RegisterBool(renderOriginal);
                CreateToggle(renderOriginal, false);

                mode = new JSONStorableBool("Mode", true, (bool _) => SyncMats());
                CreateToggle(mode, false);

                RegisterUrl(loadedShaderPath);

                CreateButton("Rescan active clothes").button.onClick.AddListener(() =>
                {
                    StartCoroutine(Rebuild());
                });
            }
            catch (Exception e)
            {
                Log.Error($"{e}");
            }
        }
Exemplo n.º 2
0
        protected void BuildUIControls()
        {
            //Diff Color
            HSVColor diffColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f);

            jDiffColor = new JSONStorableColor("DiffuseColor", diffColorHSVC, SetDiffColor);
            RegisterColor(jDiffColor);
            CreateColorPicker(jDiffColor, true);

            //Specular Color
            HSVColor specColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f);

            jSpecColor = new JSONStorableColor("SpecularColor", specColorHSVC, SetSpecColor);
            RegisterColor(jSpecColor);
            CreateColorPicker(jSpecColor, true);

            // Specular Intensity
            jSpecIntensityFloat = new JSONStorableFloat("SpecularIntensity", 0.5f, SetSpecIntensity, 0f, 1f, true);
            RegisterFloat(jSpecIntensityFloat);
            specIntensitySlider = CreateSlider(jSpecIntensityFloat);

            // Specular Sharpness
            jSpecSharpnessFloat = new JSONStorableFloat("SpecularSharpness", 6f, SetSpecSharpness, 0f, 10f, true);
            RegisterFloat(jSpecSharpnessFloat);
            specSharpnessSlider = CreateSlider(jSpecSharpnessFloat);

            // Specular Fresnel
            jSpecFresnelFloat = new JSONStorableFloat("SpecularFresnel", 0f, SetSpecFresnel, 0f, 1f, true);
            RegisterFloat(jSpecFresnelFloat);
            specFresnelSlider = CreateSlider(jSpecFresnelFloat);

            // Diffuse Offset
            jDiffOffsetFloat = new JSONStorableFloat("DiffuseOffset", 0f, SetDiffOffset, -1f, 1f, true);
            RegisterFloat(jDiffOffsetFloat);
            diffOffsetSlider = CreateSlider(jDiffOffsetFloat);

            // Spec Offset
            jSpecOffsetFloat = new JSONStorableFloat("SpecularOffset", 0f, SetSpecOffset, -1f, 1f, true);
            RegisterFloat(jSpecOffsetFloat);
            specOffsetSlider = CreateSlider(jSpecOffsetFloat);

            // Gloss Offset
            jGlossOffsetFloat = new JSONStorableFloat("GlossOffset", 0.8f, SetGlossOffset, 0, 1f, true);
            RegisterFloat(jGlossOffsetFloat);
            glossOffsetSlider = CreateSlider(jGlossOffsetFloat);

            // IBL Filter (affects Global Illum Skybox ?!)
            jIBLFilterFloat = new JSONStorableFloat("IBLFilter", 0f, SetIBLFilter, 0, 1f, true);
            RegisterFloat(jIBLFilterFloat);
            iBLFilterSlider = CreateSlider(jIBLFilterFloat);

            //Subdermis Color
            HSVColor subdermisColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f);

            jSubdermisColor = new JSONStorableColor("SubdermisColor", subdermisColorHSVC, SetSubdermisColor);
            RegisterColor(jSubdermisColor);
            CreateColorPicker(jSubdermisColor, true);
        }
Exemplo n.º 3
0
        protected void SetupPluginUI()
        {
            List <string> choices = new List <string>();

            choices.Add("None");
            choices.Add("FPS");
            choices.Add("Load Dir");
            choices.Add("Total Atoms");

            JSONStorableStringChooser jsonTypeTopLeft = new JSONStorableStringChooser("TopLeft", choices, typeTopLeft, "Top Left", SetTopLeft);
            UIDynamicPopup            dropdownTopLeft = CreatePopup(jsonTypeTopLeft);

            dropdownTopLeft.labelWidth = 300f;

            JSONStorableStringChooser jsonTypeTopRight = new JSONStorableStringChooser("TopRight", choices, typeTopRight, "Top Right", SetTopRight);
            UIDynamicPopup            dropdownTopRight = CreatePopup(jsonTypeTopRight, true);

            dropdownTopRight.labelWidth = 300f;

            JSONStorableStringChooser jsonTypeBottomLeft = new JSONStorableStringChooser("BottomLeft", choices, typeBottomLeft, "Bottom Left", SetBottomLeft);
            UIDynamicPopup            dropdownBottomLeft = CreatePopup(jsonTypeBottomLeft);

            dropdownBottomLeft.labelWidth = 300f;

            JSONStorableStringChooser jsonTypeBottomRight = new JSONStorableStringChooser("BottomRight", choices, typeBottomRight, "Bottom Right", SetBottomRight);
            UIDynamicPopup            dropdownBottomRight = CreatePopup(jsonTypeBottomRight, true);

            dropdownBottomRight.labelWidth = 300f;

            // let user adjust scale and top for HMD viewport differences and personal preference.
            JSONStorableFloat jsonTopOffset = new JSONStorableFloat("Top Offset", topOffset, SetTopOffset, -2f, +2f, true);

            RegisterFloat(jsonTopOffset);
            sliderTopOffset = CreateSlider(jsonTopOffset);

            JSONStorableFloat jsonScale = new JSONStorableFloat("HUD Scale", hudScale, SetScale, 10f, 200f, true);

            RegisterFloat(jsonScale);
            sliderScale = CreateSlider(jsonScale);

            JSONStorableFloat jsonFontSize = new JSONStorableFloat("Text Size", fontSize, SetFontSize, 10f, 100f, true);

            RegisterFloat(jsonFontSize);
            sliderFontSize = CreateSlider(jsonFontSize);


            // JSONStorableColor example
            HSVColor          hsvc          = HSVColorPicker.RGBToHSV(textColor.r, textColor.g, textColor.b);
            JSONStorableColor jsonTextColor = new JSONStorableColor("Text Color", hsvc, SetTextColor);

            RegisterColor(jsonTextColor);
            CreateColorPicker(jsonTextColor, true);
        }
Exemplo n.º 4
0
        private void ColorPicker(List <Material> mat, string shaderParamName, string displayname = null)
        {
            if (displayname == null)
            {
                displayname = shaderParamName;
            }
            var picker = new JSONStorableColor(displayname, HSVColorPicker.RGBToHSV(1f, 1f, 1f),
                                               c => mat.ForEach(m => m.SetColor(shaderParamName, c.colorPicker.currentColor))
                                               );

            script.RegisterColor(picker);
            script.CreateColorPicker(picker, true);
        }
Exemplo n.º 5
0
        public override void Init()
        {
            try {
                color = new JSONStorableColor("Color", HSVColorPicker.RGBToHSV(1f, 1f, 1f), _ => SyncMats());
                RegisterColor(color);
                CreateColorPicker(color, true);
                FloatSlider(ref alpha, "Color Alpha", 1,
                            _ => { SyncMats(); }, 0, 1, true);

                renderOriginal = new JSONStorableBool("Render Original Material", true);
                RegisterBool(renderOriginal);
                CreateToggle(renderOriginal, false);

                RegisterUrl(loadedShaderPath);

                CreateButton("Rescan active clothes").button.onClick.AddListener(() => {
                    StartCoroutine(Rebuild());
                });

                StartCoroutine(LoadShaderAndInit());
            } catch (Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }
        // IMPORTANT - DO NOT make custom enums. The dynamic C# complier crashes Unity when it encounters these for
        // some reason

        // IMPORTANT - DO NOT OVERRIDE Awake() as it is used internally by MVRScript - instead use Init() function which
        // is called right after creation
        public override void Init()
        {
            try {
                // put init code in here
                SuperController.LogMessage("Template Loaded");

                // create custom JSON storable params here if you want them to be stored with scene JSON
                // types are JSONStorableFloat, JSONStorableBool, JSONStorableString, JSONStorableStringChooser
                // JSONStorableColor

                // JSONStorableFloat example
                JSONStorableFloat jfloat = new JSONStorableFloat("FooParam", 0f, DummyFloatCallback, 0f, 5f, true);
                RegisterFloat(jfloat);
                dslider = CreateSlider(jfloat);

                // button example
                dbutton = CreateButton("FooButton");
                if (dbutton != null)
                {
                    dbutton.button.onClick.AddListener(DummyButtonCallback);
                }

                // JSONStorableColor example
                HSVColor          hsvc   = HSVColorPicker.RGBToHSV(1f, 0f, 0f);
                JSONStorableColor jcolor = new JSONStorableColor("FooColor", hsvc, DummyColorCallback);
                RegisterColor(jcolor);
                CreateColorPicker(jcolor);

                // JSONStorableString example
                jstring = new JSONStorableString("FooString", "");
                // register tells engine you want value saved in json file during save and also make it available to
                // animation/trigger system
                //RegisterString(jstring);
                dtext = CreateTextField(jstring);

                // JSONStorableStringChooser example
                List <string> choices = new List <string>();
                choices.Add("None");
                choices.Add("Choice1");
                choices.Add("Choice2");
                choices.Add("Choice3");
                JSONStorableStringChooser jchooser = new JSONStorableStringChooser("FooChooser", choices, "None", "Choose Form Of Destruction", DummyChooserCallback);
                UIDynamicPopup            udp      = CreatePopup(jchooser, true);
                //CreateScrollablePopup(jchooser, true);
                udp.labelWidth = 300f;

                JSONStorableFloat jfloat2 = new JSONStorableFloat("FooParam2", 0f, 0f, 1f);
                CreateSlider(jfloat2, true);

                // spacer example
                UIDynamic spacer = CreateSpacer(true);
                // give the popup some room
                spacer.height = 400f;

                // JSONStorableToggle example
                JSONStorableBool jbool = new JSONStorableBool("FooBool", true);
                CreateToggle(jbool, true);
            }
            catch (Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }