UnityEditor.ColorPicker.DrawColorSpaceBox C# (CSharp) Method

DrawColorSpaceBox() private method

private DrawColorSpaceBox ( Rect colorBoxRect, float constantValue ) : void
colorBoxRect UnityEngine.Rect
constantValue float
return void
        private void DrawColorSpaceBox(Rect colorBoxRect, float constantValue)
        {
            if (Event.current.type == EventType.Repaint)
            {
                if (this.m_ColorBoxMode != this.m_TextureColorBoxMode)
                {
                    int width = 0;
                    int height = 0;
                    height = 0x20;
                    if ((this.m_ColorBoxMode == ColorBoxMode.HV_S) || (this.m_ColorBoxMode == ColorBoxMode.HS_V))
                    {
                        width = 0x40;
                    }
                    else
                    {
                        width = 0x20;
                    }
                    if (this.m_ColorBox == null)
                    {
                        this.m_ColorBox = MakeTexture(width, height);
                    }
                    if ((this.m_ColorBox.width != width) || (this.m_ColorBox.height != height))
                    {
                        this.m_ColorBox.Resize(width, height);
                    }
                }
                if (((this.m_ColorBoxMode != this.m_TextureColorBoxMode) || (this.m_LastConstant != constantValue)) || this.m_ColorSpaceBoxDirty)
                {
                    float tonemappingExposureAdjusment = this.GetTonemappingExposureAdjusment();
                    float colorScale = this.GetColorScale();
                    this.m_Colors = this.m_ColorBox.GetPixels(0);
                    int xSize = this.m_ColorBox.width;
                    int ySize = this.m_ColorBox.height;
                    switch (this.m_ColorBoxMode)
                    {
                        case ColorBoxMode.SV_H:
                            FillArea(xSize, ySize, this.m_Colors, new Color(this.m_H, 0f, 0f, 1f), new Color(0f, 1f, 0f, 0f), new Color(0f, 0f, 1f, 0f));
                            HSVToRGBArray(this.m_Colors, colorScale);
                            break;

                        case ColorBoxMode.HV_S:
                            FillArea(xSize, ySize, this.m_Colors, new Color(0f, this.m_S, 0f, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 0f, 1f, 0f));
                            HSVToRGBArray(this.m_Colors, colorScale);
                            break;

                        case ColorBoxMode.HS_V:
                            FillArea(xSize, ySize, this.m_Colors, new Color(0f, 0f, this.m_V * colorScale, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 1f, 0f, 0f));
                            HSVToRGBArray(this.m_Colors, 1f);
                            break;

                        case ColorBoxMode.BG_R:
                            FillArea(xSize, ySize, this.m_Colors, new Color(this.m_R * colorScale, 0f, 0f, 1f), new Color(0f, 0f, colorScale, 0f), new Color(0f, colorScale, 0f, 0f));
                            break;

                        case ColorBoxMode.BR_G:
                            FillArea(xSize, ySize, this.m_Colors, new Color(0f, this.m_G * colorScale, 0f, 1f), new Color(0f, 0f, colorScale, 0f), new Color(colorScale, 0f, 0f, 0f));
                            break;

                        case ColorBoxMode.RG_B:
                            FillArea(xSize, ySize, this.m_Colors, new Color(0f, 0f, this.m_B * colorScale, 1f), new Color(colorScale, 0f, 0f, 0f), new Color(0f, colorScale, 0f, 0f));
                            break;
                    }
                    if (QualitySettings.activeColorSpace == ColorSpace.Linear)
                    {
                        LinearToGammaArray(this.m_Colors);
                    }
                    DoTonemapping(this.m_Colors, tonemappingExposureAdjusment, this.m_HDRValues.m_TonemappingType);
                    this.m_ColorBox.SetPixels(this.m_Colors, 0);
                    this.m_ColorBox.Apply(true);
                    this.m_LastConstant = constantValue;
                    this.m_TextureColorBoxMode = (int) this.m_ColorBoxMode;
                }
                Graphics.DrawTexture(colorBoxRect, this.m_ColorBox, new Rect(0.5f / ((float) this.m_ColorBox.width), 0.5f / ((float) this.m_ColorBox.height), 1f - (1f / ((float) this.m_ColorBox.width)), 1f - (1f / ((float) this.m_ColorBox.height))), 0, 0, 0, 0, Color.grey);
                DrawLabelOutsideRect(colorBoxRect, this.GetXAxisLabel(this.m_ColorBoxMode), LabelLocation.Bottom);
                DrawLabelOutsideRect(colorBoxRect, this.GetYAxisLabel(this.m_ColorBoxMode), LabelLocation.Left);
            }
        }