Exemple #1
0
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

        if (!parsed)
        {
            parsed      = true;
            parsedLabel = RTP_MatPropStringParser.Parse(label);
        }
        label = parsedLabel;

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag)
            {
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);

                EditorGUIUtility.labelWidth = 300;
                EditorGUI.BeginChangeCheck();
                float pval = prop.floatValue;
                float nval = EditorGUI.Popup(position, label, (int)pval, props);
                if (EditorGUI.EndChangeCheck())
                {
                    prop.floatValue = nval;
                }

                EditorGUI.EndDisabledGroup();
            }
        }
    }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (!customEditor.showFlag)
            {
                return;
            }

            if (!parsed)
            {
                parsed      = true;
                parsedLabel = RTP_MatPropStringParser.Parse(label);
            }
            label = parsedLabel;

            Color col  = GUI.contentColor;
            Color bcol = GUI.backgroundColor;
            GUI.contentColor    = new Color(1f, 1f, 0.8f, 1f);
            GUI.backgroundColor = backgroundColor;

            Rect pos = new Rect(position);
            pos.y      += 3;
            pos.height -= 3;

            //if (visibilityProp1 != null)
            //{
            //    pos.x += 12;
            //    pos.width -= 12;
            //}

            EditorGUI.HelpBox(pos, (foldoutFlag ? "     " : "") + label, MessageType.None);

            if (foldoutFlag)
            {
                Rect fpos = new Rect(pos);
                fpos.x += 15;
                fpos.y += 1;
                bool state = EditorGUI.Foldout(fpos, prop.floatValue == 1, "", true);
                prop.floatValue = state ? 1 : 0;
            }

            GUI.contentColor    = col;
            GUI.backgroundColor = bcol;
        }
    }
Exemple #3
0
 public RTP_HeaderDecorator(string headerLabel, string layer_flag) : base()
 {
     this.headerLabel  = RTP_MatPropStringParser.Parse(headerLabel);
     active_layer_flag = true;
 }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

        if (!parsed)
        {
            parsed      = true;
            parsedLabel = RTP_MatPropStringParser.Parse(label);
        }
        label = parsedLabel;

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag && (show_for_active_layer == -1 || customEditor.active_layer == show_for_active_layer) && prop.name != "dummy_end")
            {
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);

                switch (prop.type)
                {
                //case MaterialProperty.PropType.Range: // float ranges
                //    {
                //        editor.RangeProperty(position, prop, label);
                //        break;
                //    }
                //case MaterialProperty.PropType.Float: // floats
                //    {
                //        editor.FloatProperty(position, prop, label);
                //        break;
                //    }
                case MaterialProperty.PropType.Color:     // colors
                {
                    EditorGUIUtility.labelWidth -= 30;
                    if (noAlphaFlag)
                    {
#if !UNITY_2018_1_OR_NEWER
                        prop.colorValue = EditorGUI.ColorField(position, new GUIContent(label, ""), prop.colorValue, true, false, false, null);
#else
                        prop.colorValue = EditorGUI.ColorField(position, new GUIContent(label, ""), prop.colorValue, true, false, false);
#endif
                    }
                    else
                    {
                        editor.ColorProperty(position, prop, label);
                    }
                    break;
                }

                case MaterialProperty.PropType.Texture:     // textures
                {
                    EditorGUI.BeginChangeCheck();
                    if (miniThumbFlag)
                    {
                        editor.TexturePropertyMiniThumbnail(position, prop, label, "");
                    }
                    else
                    {
                        editor.TextureProperty(position, prop, label, !noTileOffsetFlag);
                    }
                    if (EditorGUI.EndChangeCheck() && prop.textureValue != null && sharedTextures != null)
                    {
                        for (int j = 0; j < sharedTextures.Length; j++)
                        {
                            foreach (Material mat in editor.targets)
                            {
                                if (mat.HasProperty(sharedTextures[j]))
                                {
                                    mat.SetTexture(sharedTextures[j], prop.textureValue);
                                }
                            }
                        }
                    }
                    break;
                }

                case MaterialProperty.PropType.Vector:     // vectors
                {
                    if (byLayerFlag)
                    {
                        //
                        // affect single vector component depending on active layer
                        //
                        int   layerNum = customEditor.active_layer;
                        float pval     = prop.vectorValue[layerNum];
                        float nval;
                        if (minVal == maxVal)
                        {
                            // float
                            EditorGUIUtility.labelWidth -= 23;
                            nval = EditorGUI.FloatField(position, label, pval);
                        }
                        else
                        {
                            // slider
                            EditorGUIUtility.labelWidth = 160;
                            nval = EditorGUI.Slider(position, label, pval, minVal, maxVal);
                        }
                        if (pval != nval)
                        {
                            for (int i = 0; i < prop.targets.Length; i++)
                            {
                                Material mat = (prop.targets[i] as Material);
                                Vector4  vec = mat.GetVector(prop.name);
                                vec[layerNum] = nval;
                                mat.SetVector(prop.name, vec);
                            }
                        }
                    }
                    else
                    {
                        position.x     += 12;
                        position.width -= 12;
                        editor.VectorProperty(position, prop, label);
                    }
                    break;
                }

                default:
                {
                    if (customEditor.nextLabelWidth > 0)
                    {
                        EditorGUIUtility.labelWidth = customEditor.nextLabelWidth;
                        customEditor.nextLabelWidth = 0;
                    }
                    else
                    {
                        EditorGUIUtility.labelWidth -= 30;
                    }
                    editor.DefaultShaderProperty(position, prop, label);
                    break;
                }
                }

                EditorGUI.EndDisabledGroup();
            }
        }
    }
Exemple #5
0
 public RTP_TooltipDecorator(string toolTip) : base()
 {
     this.toolTip = RTP_MatPropStringParser.Parse(toolTip);
 }