UnityEditor.ColorPicker.LinearToGammaArray C# (CSharp) Method

LinearToGammaArray() private static method

private static LinearToGammaArray ( Color colors ) : void
colors Color
return void
        private static void LinearToGammaArray(Color[] colors)
        {
            int length = colors.Length;
            for (int i = 0; i < length; i++)
            {
                Color color = colors[i];
                Color gamma = color.gamma;
                gamma.a = color.a;
                colors[i] = gamma;
            }
        }

Usage Example

示例#1
0
        private void DrawColorSpaceBox(Rect colorBoxRect, float constantValue)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (this.m_ColorBoxMode != (ColorPicker.ColorBoxMode) this.m_TextureColorBoxMode)
            {
                int num = 8;
                int num2;
                if (this.m_ColorBoxMode == ColorPicker.ColorBoxMode.HV_S || this.m_ColorBoxMode == ColorPicker.ColorBoxMode.HS_V)
                {
                    num2 = 64;
                }
                else
                {
                    num2 = 8;
                }
                if (this.m_ColorBox == null)
                {
                    this.m_ColorBox = ColorPicker.MakeTexture(num2, num);
                }
                if (this.m_ColorBox.width != num2 || this.m_ColorBox.height != num)
                {
                    this.m_ColorBox.Resize(num2, num);
                }
            }
            if (this.m_ColorBoxMode != (ColorPicker.ColorBoxMode) this.m_TextureColorBoxMode || this.m_LastConstant != constantValue)
            {
                this.m_Colors = this.m_ColorBox.GetPixels(0);
                int width  = this.m_ColorBox.width;
                int height = this.m_ColorBox.height;
                switch (this.m_ColorBoxMode)
                {
                case ColorPicker.ColorBoxMode.SV_H:
                    ColorPicker.FillArea(width, height, this.m_Colors, new Color(this.m_H, 0f, 0f, 1f), new Color(0f, 1f, 0f, 0f), new Color(0f, 0f, 1f, 0f));
                    ColorPicker.HSVToRGBArray(this.m_Colors);
                    break;

                case ColorPicker.ColorBoxMode.HV_S:
                    ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, this.m_S, 0f, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 0f, 1f, 0f));
                    ColorPicker.HSVToRGBArray(this.m_Colors);
                    break;

                case ColorPicker.ColorBoxMode.HS_V:
                    ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, 0f, this.m_V, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 1f, 0f, 0f));
                    ColorPicker.HSVToRGBArray(this.m_Colors);
                    break;

                case ColorPicker.ColorBoxMode.BG_R:
                    ColorPicker.FillArea(width, height, this.m_Colors, new Color(this.m_R, 0f, 0f, 1f), new Color(0f, 0f, 1f, 0f), new Color(0f, 1f, 0f, 0f));
                    break;

                case ColorPicker.ColorBoxMode.BR_G:
                    ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, this.m_G, 0f, 1f), new Color(0f, 0f, 1f, 0f), new Color(1f, 0f, 0f, 0f));
                    break;

                case ColorPicker.ColorBoxMode.RG_B:
                    ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, 0f, this.m_B, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 1f, 0f, 0f));
                    break;
                }
                if (QualitySettings.activeColorSpace == ColorSpace.Linear)
                {
                    ColorPicker.LinearToGammaArray(this.m_Colors);
                }
                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);
        }
All Usage Examples Of UnityEditor.ColorPicker::LinearToGammaArray