Esempio n. 1
0
        public Color EditorGUIColorField(Rect position, GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, ColorPickerHDRConfig hdrConfig)
        {
            Color newValue = EditorGUI.ColorField(position, label, value, showEyedropper, showAlpha, hdr, hdrConfig);

            if (newValue != value)
            {
                UndoRecordObject(this, string.Format(MessageFormat, label, ((m_nodeAttribs != null) ? m_nodeAttribs.Name : GetType().ToString())));
            }
            return(newValue);
        }
Esempio n. 2
0
        public Color EditorGUILayoutColorField(GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, ColorPickerHDRConfig hdrConfig, params GUILayoutOption[] options)
        {
            Color newValue = EditorGUILayout.ColorField(label, value, showEyedropper, showAlpha, hdr, hdrConfig, options);

            if (newValue != value)
            {
                UndoRecordObject(string.Format(MessageFormat, label, ((m_nodeAttribs != null) ? m_nodeAttribs.Name : GetType().ToString())));
            }
            return(newValue);
        }
            public static Vector4 DoGUI(Rect area, string title, Vector4 vec, float rgbMin, float rgbMax)
            {
                if (s_centeredLabelStyle == null)
                {
                    s_centeredLabelStyle = new GUIStyle(GUI.skin.GetStyle("Label"))
                    {
                        alignment = TextAnchor.MiddleCenter
                    };
                }

                if (s_centeredSliderStyle == null)
                {
                    s_centeredSliderStyle = new GUIStyle(GUI.skin.GetStyle("VerticalSlider"))
                    {
                        alignment = TextAnchor.UpperCenter
                    };
                }

                if (s_sliderThumbStyle == null)
                {
                    s_sliderThumbStyle = new GUIStyle(GUI.skin.GetStyle("VerticalSliderThumb"));
                }

                GUILayout.Label(title, s_centeredLabelStyle);

                ColorPickerHDRConfig hdrConfig = new ColorPickerHDRConfig(rgbMin, rgbMax, 0, 1);

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    GUIContent content = new GUIContent();
                    vec = EditorGUILayout.ColorField(content, vec, false, false, true, hdrConfig, GUILayout.MaxWidth(80), GUILayout.Height(20));
                    GUILayout.FlexibleSpace();
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginVertical("box");
                {
                    // HSV Value Slider
                    {
                        Color color = vec;

                        float h = 0;
                        float s = 0;
                        float v = 0;

                        Color.RGBToHSV(color, out h, out s, out v);

                        if (v == 0 && color.grayscale != 0)
                        {
                            v = color.grayscale;
                        }

                        v   = GUILayout.HorizontalSlider(v, rgbMin, rgbMax);
                        vec = Color.HSVToRGB(h, s, v, true);
                    }

                    // RGB Sliders
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        vec.x = DrawColorSlider("R", vec.x, rgbMin, rgbMax, Color.red);
                        vec.y = DrawColorSlider("G", vec.y, rgbMin, rgbMax, Color.green);
                        vec.z = DrawColorSlider("B", vec.z, rgbMin, rgbMax, Color.blue);
                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();

                vec.x = Mathf.Clamp(vec.x, rgbMin, rgbMax);
                vec.y = Mathf.Clamp(vec.y, rgbMin, rgbMax);
                vec.z = Mathf.Clamp(vec.z, rgbMin, rgbMax);

                return(vec);
            }