override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     //Debug.Log("OnGUI: " + label + " RTP_BeginAreaDecorator");
     if (editor is RTP_CustomShaderGUI)
     {
         RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
         //if (label == "Triplanar tile size")
         //{
         //    Debug.Log("E"+ customEditor.test);
         //    customEditor.test++;
         //}
         //if (!customEditor.helperFlag)
         //{
         //    customEditor.helperFlag = true;
         //    return 0;
         //}
         //customEditor.helperFlag = false;
         if (customEditor.showFlag)
         {
             if (indent)
             {
                 EditorGUILayout.BeginHorizontal();
                 GUILayout.Space(indentVal);
             }
             if (type == "none")
             {
                 EditorGUILayout.BeginVertical();
             }
             else
             {
                 EditorGUILayout.BeginVertical(type);
             }
         }
     }
 }
Exemplo n.º 2
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 float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("GetHeight: " + label+ " RTP_MaterialProp" );

        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")
            {
                if (miniThumbFlag)
                {
                    return(20);
                }
                else
                {
                    if ((prop.type == MaterialProperty.PropType.Vector) && byLayerFlag)
                    {
                        return(17);
                    }
                    else
                    {
                        return(MaterialEditor.GetDefaultPropertyHeight(prop));
                    }
                }
            }
            return(-2);
        }
        return(MaterialEditor.GetDefaultPropertyHeight(prop));
    }
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("GetHeight: " + label + " RTP_EndAreaDecorator");
        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
            if (customEditor.helperFlag)
            {
                customEditor.helperFlag = false;
                return(0);
            }
            customEditor.helperFlag = true;
            if (customEditor.showFlag)
            {
                EditorGUILayout.EndVertical();
                if (indent)
                {
                    // EditorGUI.indentLevel--;

                    EditorGUILayout.EndHorizontal();
                }
            }
        }
        return(0);
    }
 override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (editor is RTP_CustomShaderGUI)
     {
         RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
         if (customEditor.showFlag)
         {
             return(20);
         }
         return(-2);
     }
     return(0);
 }
Exemplo n.º 6
0
    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)
            {
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.width = Mathf.Min(rect.width, EditorGUIUtility.labelWidth);
                EditorGUI.LabelField(rect, new GUIContent("", toolTip));
            }
        }
    }
Exemplo n.º 7
0
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_HeaderDecorator");

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

            if (customEditor.showFlag)
            {
                customEditor.nextLabelWidth = nextLabelWidth;
            }
        }
    }
Exemplo n.º 8
0
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("GetHeight: " + label+ " RTP_MaterialProp" );

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
            if (customEditor.showFlag)
            {
                return(20);
            }
            return(-2);
        }
        return(MaterialEditor.GetDefaultPropertyHeight(prop));
    }
    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;
        }
    }
Exemplo n.º 10
0
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_HeaderDecorator");

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

            if (customEditor.showFlag)
            {
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);
                position.y += 2;
                EditorGUI.LabelField(position, headerLabel + (active_layer_flag ? " " + (customEditor.active_layer + 1) : ""), EditorStyles.boldLabel);
                EditorGUI.EndDisabledGroup();
            }
        }
    }
Exemplo n.º 11
0
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

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

            if (customEditor.showFlag)
            {
                bool featureActive = customEditor.CheckDefine(prop.name, false);
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);
                EditorGUI.BeginChangeCheck();
                bool  feature_doesntFit = (featureActive != prop.floatValue > 0);
                Color col = GUI.color;
                if (feature_doesntFit)
                {
                    GUI.color = new Color(1, 0.6f, 0.6f, 1);
                }
                float nval = EditorGUILayout.ToggleLeft(new GUIContent(label, toolTip), prop.floatValue > 0 ? true:false, feature_doesntFit ? EditorStyles.boldLabel : EditorStyles.label) ? 1:0;
                GUI.color = col;
                if (EditorGUI.EndChangeCheck())
                {
                    prop.floatValue = nval;
                    if (nval == 0 && dependentFeatures != null)
                    {
                        for (int i = 0; i < dependentFeatures.Length; i++)
                        {
                            if ((editor.target as Material).HasProperty(dependentFeatures[i]))
                            {
                                foreach (Material mat in editor.targets)
                                {
                                    mat.SetFloat(dependentFeatures[i], 0);
                                }
                            }
                        }
                    }
                }

                EditorGUI.EndDisabledGroup();
            }
        }
    }
Exemplo n.º 12
0
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("GetHeight: " + label + " RTP_HideByPropDecorator");

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
            if (clearFlag)
            {
                customEditor.showFlag     = true;
                customEditor.inactiveFlag = false;
            }
            else
            {
                customEditor.showFlag = checkVisible(editor, ref customEditor.inactiveFlag);
            }
        }
        return(0);
    }
Exemplo n.º 13
0
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " Button");

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

            if (customEditor.showFlag)
            {
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);
                Rect rect = position;
                if (GUI.Button(rect, buttonLabel))
                {
                    Type       thisType  = customEditor.GetType();
                    MethodInfo theMethod = thisType.GetMethod(functionName);
                    theMethod.Invoke(customEditor, new System.Object[] { });//, userParameters);
                }
                EditorGUI.EndDisabledGroup();
            }
        }
    }
    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();
            }
        }
    }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

        for (int i = 0; i < numLayers; i++)
        {
            thumbs[i] = MaterialEditor.GetMaterialProperty(editor.targets, thumbPropNames[i]);
        }

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

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

                EditorGUILayout.BeginVertical("Box");
                Color skin_color = GUI.color;
                GUI.color = new Color(1, 1, 0.5f, 1);
                EditorGUILayout.LabelField("Choose layer", EditorStyles.boldLabel);
                GUI.color = skin_color;
                //EditorGUILayout.HelpBox("Hint: to quickly select a layer - focus on scene view (by click) and press L holding cursor over the layer that should be selected.", MessageType.Info, true);

                GUISkin    gs  = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
                RectOffset ro1 = gs.label.padding;
                RectOffset ro2 = gs.label.margin;
                gs.label.padding = new RectOffset(0, 0, 0, 0);
                gs.label.margin  = new RectOffset(3, 3, 3, 3);
                int thumb_size = 50;
                int per_row    = Mathf.Max(4, (Screen.width) / thumb_size - 1);
                thumb_size = (Screen.width - thumb_size - 2 * per_row) / per_row;
                Color ccol = GUI.contentColor;
                for (int n = 0; n < numLayers; n++)
                {
                    if ((n % per_row) == 0)
                    {
                        EditorGUILayout.BeginHorizontal();
                    }
                    Color bcol = GUI.backgroundColor;
                    if (n == prop.floatValue)
                    {
                        GUI.contentColor    = new Color(1, 1, 1, 1);
                        GUI.backgroundColor = new Color(1, 1, 0, 1);
                        EditorGUILayout.BeginHorizontal("Box");
                        if (thumbs[n].textureValue)
                        {
                            GUILayout.Label((Texture2D)AssetPreview.GetAssetPreview(thumbs[n].textureValue), GUILayout.Width(thumb_size - 8), GUILayout.Height(thumb_size - 8));
                        }
                        else
                        {
                            GUILayout.Label(customEditor.blankGreyTex, GUILayout.Width(thumb_size - 8), GUILayout.Height(thumb_size - 8));
                        }
                    }
                    else
                    {
                        GUI.contentColor = new Color(1, 1, 1, 0.5f);
                        if (thumbs[n].textureValue)
                        {
                            if (GUILayout.Button((Texture2D)AssetPreview.GetAssetPreview(thumbs[n].textureValue), "Label", GUILayout.Width(thumb_size), GUILayout.Height(thumb_size)))
                            {
                                GUI.FocusControl("");
                                prop.floatValue = n;
                            }
                        }
                        else
                        {
                            if (GUILayout.Button(customEditor.blankGreyTex, "Label", GUILayout.Width(thumb_size), GUILayout.Height(thumb_size)))
                            {
                                GUI.FocusControl("");
                                prop.floatValue = n;
                            }
                        }
                    }
                    if (n == prop.floatValue)
                    {
                        EditorGUILayout.EndHorizontal();
                        GUI.backgroundColor = bcol;
                    }
                    if ((n % per_row) == (per_row - 1) || n == numLayers - 1)
                    {
                        EditorGUILayout.EndHorizontal();
                    }
                }
                GUI.contentColor = ccol;
                gs.label.padding = ro1;
                gs.label.margin  = ro2;
                EditorGUILayout.EndVertical();

                EditorGUI.EndDisabledGroup();
            }
        }
    }
Exemplo n.º 16
0
    protected bool checkVisible(MaterialEditor editor, ref bool inactiveFlagOut)
    {
        bool visible = false;

        // 1st level
        if (visibilityProp1 != "")
        {
            Material mat       = editor.target as Material;
            string   firstChar = visibilityProp1.Substring(0, 1);
            if ((firstChar.ToUpper() == firstChar) && (editor is RTP_CustomShaderGUI))
            {
                RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
                if (customEditor.shaderCode != null)
                {
                    visible = customEditor.CheckDefine(visibilityProp1, invertFlag);
                    if (!visible && inactiveFlag1)
                    {
                        inactiveFlagOut = true;
                    }
                    visible = visible || inactiveFlag1;
                }
            }
            else
            {
                if (mat.HasProperty(visibilityProp1))
                {
                    float val = mat.GetFloat(visibilityProp1);
                    for (int i = 0; i < visibilityPropVals1.Length; i++)
                    {
                        visible = visible || (val == visibilityPropVals1[i]);
                    }
                    if (!visible && inactiveFlag1)
                    {
                        inactiveFlagOut = true;
                    }
                    visible = visible || inactiveFlag1;
                }
            }
        }
        if (!BoolOrFlag && !visible)
        {
            return(false);
        }

        // 2nd nested level
        if (visibilityProp2 != "")
        {
            Material mat = editor.target as Material;
            if (mat.HasProperty(visibilityProp2))
            {
                visible = false;
                float val = mat.GetFloat(visibilityProp2);
                for (int i = 0; i < visibilityPropVals2.Length; i++)
                {
                    visible = visible || (val == visibilityPropVals2[i]);
                }
                if (!visible && inactiveFlag2)
                {
                    inactiveFlagOut = true;
                }
                visible = visible || inactiveFlag2;
            }
        }

        return(visible);
    }