Esempio n. 1
0
 public static MaterialProperty[] GetProperties(MaterialEditor editor)
 {
     if (editor.customShaderGUI != null && editor.customShaderGUI is SimpleShaderGUI)
     {
         SimpleShaderGUI gui = editor.customShaderGUI as SimpleShaderGUI;
         return(gui.props);
     }
     else
     {
         Debug.LogWarning("TA.SimpleShaderGUI to the end of your shader!");
         return(null);
     }
 }
Esempio n. 2
0
        public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            EditorGUI.ColorField(new Rect(-999, 0, 0, 0), new Color(0, 0, 0, 0));

            var r = EditorGUILayout.GetControlRect();
            MaterialProperty p = null;

            if (extraPropName != "" && extraPropName != "_")
            {
                p = SimpleShaderGUI.FindProp(extraPropName, props, true);
            }

            if (p != null)
            {
                Rect rect = Rect.zero;
                if (p.type == MaterialProperty.PropType.Range)
                {
                    var w = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 0;
                    rect = MaterialEditor.GetRectAfterLabelWidth(r);
                    EditorGUIUtility.labelWidth = w;
                }
                else
                {
                    rect = MaterialEditor.GetRectAfterLabelWidth(r);
                }

                editor.TexturePropertyMiniThumbnail(r, prop, label.text, label.tooltip);

                var i = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                editor.ShaderProperty(rect, p, string.Empty);
                EditorGUI.indentLevel = i;
            }
            else
            {
                EditorGUI.showMixedValue = prop.hasMixedValue;
                editor.TexturePropertyMiniThumbnail(r, prop, label.text, label.tooltip);
            }
            EditorGUI.showMixedValue = false;
        }
Esempio n. 3
0
        public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            Stack <MaterialProperty> cProps = new Stack <MaterialProperty>();

            for (int i = 0; i < 4; i++)
            {
                if (i == 0)
                {
                    cProps.Push(prop);
                    continue;
                }
                var p = SimpleShaderGUI.FindProp(colorStr[i - 1], props);
                if (p != null && p.type == MaterialProperty.PropType.Color)
                {
                    cProps.Push(p);
                }
            }
            int count = cProps.Count;

            var rect = EditorGUILayout.GetControlRect();

            var p1 = cProps.Pop();

            EditorGUI.showMixedValue = p1.hasMixedValue;
            editor.ColorProperty(rect, p1, label.text);

            for (int i = 1; i < count; i++)
            {
                var cProp = cProps.Pop();
                EditorGUI.showMixedValue = cProp.hasMixedValue;
                Rect  r        = new Rect(rect);
                var   interval = 13 * i * (-0.25f + EditorGUI.indentLevel * 1.25f);
                float w        = propRight * (0.8f + EditorGUI.indentLevel * 0.2f);
                r.xMin += r.width - w * (i + 1) + interval;
                r.xMax -= w * i - interval;

                EditorGUI.BeginChangeCheck();
                Color src, dst;
                if (isHSV)
                {
                    src = Func.HSVToRGB(cProp.colorValue.linear).gamma;
                }
                else
                {
                    src = cProp.colorValue;
                }
                var hdr = (prop.flags & MaterialProperty.PropFlags.HDR) != MaterialProperty.PropFlags.None;
                dst = EditorGUI.ColorField(r, GUIContent.none, src, true, true, hdr);
                if (EditorGUI.EndChangeCheck())
                {
                    if (isHSV)
                    {
                        cProp.colorValue = Func.RGBToHSV(dst.linear).gamma;
                    }
                    else
                    {
                        cProp.colorValue = dst;
                    }
                }
            }
            EditorGUI.showMixedValue = false;
            Func.SetShaderKeyWord(editor.targets, preHSVKeyWord, isHSV);
        }