Пример #1
0
        public void DrawSurfaceInputs(Material material)
        {
            EditorGUILayout.LabelField(new GUIContent("Colors"), CustomGUIStyles.LabelBold);

            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel += 2;

            MaterialEditorHelper.DrawTwoValueFieldColor(
                EditorGUILayout.GetControlRect(),
                l_color1, 0f, false,
                GUIContent.none, p_color1High,
                GUIContent.none, p_color1Low);

            EditorGUI.indentLevel = oldIndent + 1;

            if (DrawTogglableColorField(l_color2, p_hasColor2, p_color2High, p_color2Low))
            {
                if (DrawTogglableColorField(l_color3, p_hasColor3, p_color3High, p_color3Low))
                {
                    DrawTogglableColorField(l_color4, p_hasColor4, p_color4High, p_color4Low);
                }
            }

            EditorGUI.indentLevel = oldIndent;
        }
Пример #2
0
        private bool DrawTogglableColorField(
            GUIContent label,
            MaterialProperty hasColor,
            MaterialProperty colorHigh,
            MaterialProperty colorLow)
        {
            Rect     position  = EditorGUILayout.GetControlRect();
            Rect     togglePos = new Rect(position.position, new Vector2(EditorGUIUtility.labelWidth, position.height));
            GUIStyle style;

            if (hasColor.floatValue == 0.0f)
            {
                style = CustomGUIStyles.Disabled;
            }
            else
            {
                style = GUIStyle.none;
            }
            hasColor.floatValue = EditorGUI.ToggleLeft(togglePos, label, hasColor.floatValue > 0.0f, style) ? 1.0f : 0.0f;
            if (hasColor.floatValue > 0.0)
            {
                MaterialEditorHelper.DrawTwoValueFieldColor(position,
                                                            new GUIContent(" "), 0f, false, // Using a dummy 'spacer' GUIContent
                                                            GUIContent.none, colorHigh,
                                                            GUIContent.none, colorLow);

                return(true);
            }
            return(false);
        }