DrawPreview() public static method

public static DrawPreview ( Rect position ) : void
position UnityEngine.Rect
return void
示例#1
0
        private void DoColorSpaceGUI()
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.m_ShowColors = GUILayout.Toggle(this.m_ShowColors, ColorPicker.styles.colorToggle, EditorStyles.foldout, new GUILayoutOption[0]);
            GUI.enabled       = this.m_ShowColors;
            if (GUILayout.Button(ColorPicker.styles.colorCycle, GUIStyle.none, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            }))
            {
                this.m_OldColorBoxMode = (this.m_ColorBoxMode = (this.m_ColorBoxMode + 1) % ColorPicker.ColorBoxMode.EyeDropper);
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            if (this.m_ShowColors)
            {
                bool changed = GUI.changed;
                GUILayout.BeginHorizontal(new GUILayoutOption[]
                {
                    GUILayout.ExpandHeight(false)
                });
                Rect aspectRect = GUILayoutUtility.GetAspectRect(1f, ColorPicker.styles.pickerBox, new GUILayoutOption[]
                {
                    GUILayout.MinWidth(64f),
                    GUILayout.MinHeight(64f),
                    GUILayout.MaxWidth(256f),
                    GUILayout.MaxHeight(256f)
                });
                EditorGUILayout.Space();
                Rect rect = GUILayoutUtility.GetRect(8f, 32f, 64f, 128f, ColorPicker.styles.pickerBox);
                rect.height = aspectRect.height;
                GUILayout.EndHorizontal();
                GUI.changed = false;
                switch (this.m_ColorBoxMode)
                {
                case ColorPicker.ColorBoxMode.SV_H:
                    this.Slider3D(aspectRect, rect, ref this.m_S, ref this.m_V, ref this.m_H, ColorPicker.styles.pickerBox, ColorPicker.styles.thumb2D, ColorPicker.styles.thumbVert);
                    if (GUI.changed)
                    {
                        this.HSVToRGB();
                    }
                    break;

                case ColorPicker.ColorBoxMode.HV_S:
                    this.Slider3D(aspectRect, rect, ref this.m_H, ref this.m_V, ref this.m_S, ColorPicker.styles.pickerBox, ColorPicker.styles.thumb2D, ColorPicker.styles.thumbVert);
                    if (GUI.changed)
                    {
                        this.HSVToRGB();
                    }
                    break;

                case ColorPicker.ColorBoxMode.HS_V:
                    this.Slider3D(aspectRect, rect, ref this.m_H, ref this.m_S, ref this.m_V, ColorPicker.styles.pickerBox, ColorPicker.styles.thumb2D, ColorPicker.styles.thumbVert);
                    if (GUI.changed)
                    {
                        this.HSVToRGB();
                    }
                    break;

                case ColorPicker.ColorBoxMode.BG_R:
                    this.Slider3D(aspectRect, rect, ref this.m_B, ref this.m_G, ref this.m_R, ColorPicker.styles.pickerBox, ColorPicker.styles.thumb2D, ColorPicker.styles.thumbVert);
                    if (GUI.changed)
                    {
                        this.RGBToHSV();
                    }
                    break;

                case ColorPicker.ColorBoxMode.BR_G:
                    this.Slider3D(aspectRect, rect, ref this.m_B, ref this.m_R, ref this.m_G, ColorPicker.styles.pickerBox, ColorPicker.styles.thumb2D, ColorPicker.styles.thumbVert);
                    if (GUI.changed)
                    {
                        this.RGBToHSV();
                    }
                    break;

                case ColorPicker.ColorBoxMode.RG_B:
                    this.Slider3D(aspectRect, rect, ref this.m_R, ref this.m_G, ref this.m_B, ColorPicker.styles.pickerBox, ColorPicker.styles.thumb2D, ColorPicker.styles.thumbVert);
                    if (GUI.changed)
                    {
                        this.RGBToHSV();
                    }
                    break;

                case ColorPicker.ColorBoxMode.EyeDropper:
                    EyeDropper.DrawPreview(Rect.MinMaxRect(aspectRect.x, aspectRect.y, rect.xMax, aspectRect.yMax));
                    break;
                }
                GUI.changed |= changed;
            }
        }