Exemplo n.º 1
0
        protected override void DrawGUI(Rect position, TCP2_Config config)
        {
            var currentValueStr = config.GetKeyword(keyword);
            var currentValue    = defaultValue;

            if (!float.TryParse(currentValueStr, out currentValue))
            {
                currentValue = defaultValue;

                //Only enforce keyword if feature is enabled
                if (Enabled(config))
                {
                    config.SetKeyword(keyword, currentValue.ToString("0.0###############"));
                }
            }

            EditorGUI.BeginChangeCheck();
            var newValue = currentValue;

            newValue = Mathf.Clamp(EditorGUI.FloatField(position, currentValue), min, max);
            if (EditorGUI.EndChangeCheck())
            {
                if (newValue != currentValue)
                {
                    config.SetKeyword(keyword, newValue.ToString("0.0###############"));
                }
            }
        }
Exemplo n.º 2
0
        private int GetSelectedValue(TCP2_Config config)
        {
            var currentValue = config.GetKeyword(keyword);

            for (var i = 0; i < values.Length; i++)
            {
                if (currentValue == values[i])
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemplo n.º 3
0
        int GetCurrentMask(TCP2_Config config)
        {
            var curMask = Array.IndexOf(masks, config.GetKeyword(maskKeyword));

            return(curMask);
        }
Exemplo n.º 4
0
        protected override void DrawGUI(Rect position, TCP2_Config config)
        {
            //GUIMask(config, this.label, this.tooltip, this.maskKeyword, this.channelKeyword, this.keyword, this.Enabled(config), this.increaseIndent, helpTopic: this.helpTopic, helpIndent: this.helpIndent);

            var curMask = Array.IndexOf(masks, config.GetKeyword(maskKeyword));

            if (curMask < 0)
            {
                curMask = 0;
            }
            var curChannel = TCP2_Utils.FromShader(config.GetKeyword(channelKeyword));
            var uvKey      = (curMask > 1 && curMask < 5) ? "UV_" + masks[curMask] : null;
            var curUv      = Array.IndexOf(uvs, config.GetKeyword(uvKey));

            if (curUv < 0)
            {
                curUv = 0;
            }

            EditorGUI.BeginChangeCheck();

            //Calculate rects
            var helpButton = position;

            helpButton.width = 16f;
            helpButton.x    += 2f;
            position.width  -= helpButton.width;
            helpButton.x    += position.width;

            //Mask type (MainTex, 1, 2, 3)
            var sideRect = position;

            sideRect.width = position.width * 0.75f / 2f;
            curMask        = EditorGUI.Popup(sideRect, curMask, labels);

            //Mask Channel (RGBA)
            var middleRect = position;

            middleRect.width = position.width * 0.25f;
            middleRect.x    += sideRect.width;
            GUI.enabled     &= curMask > 0;
            curChannel       = (TCP2_Utils.TextureChannel)EditorGUI.EnumPopup(middleRect, curChannel);

            //Mask UVs
            sideRect.x  += sideRect.width + middleRect.width;
            GUI.enabled &= curMask > 1 && curMask < 5;
            curUv        = EditorGUI.Popup(sideRect, curUv, uvs);

            //Mask Help
            TCP2_GUI.HelpButton(helpButton, "Masks");

            if (EditorGUI.EndChangeCheck())
            {
                config.SetKeyword(maskKeyword, masks[curMask]);
                if (curMask > 0)
                {
                    config.SetKeyword(channelKeyword, curChannel.ToShader());
                }
                if (curMask > 1 && !string.IsNullOrEmpty(uvKey))
                {
                    config.SetKeyword(uvKey, uvs[curUv]);
                }
                config.ToggleFeature("VCOLORS_MASK", (curMask == 5));
                config.ToggleFeature(keyword, (curMask > 0));
            }
        }
        int GetCurrentMask(TCP2_Config config)
        {
            int curMask = System.Array.IndexOf(masks, config.GetKeyword(this.maskKeyword));

            return(curMask);
        }