private void RegenerateSVTexture()
        {
            double h = colorPicker != null ? colorPicker.H * 360 : 0;

            if (image.texture != null)
            {
                DestroyImmediate(image.texture);
            }

            Texture2D texture = new Texture2D(textureWidth, textureHeight)
            {
                wrapMode  = TextureWrapMode.Clamp,
                hideFlags = HideFlags.DontSave
            };

            for (int s = 0; s < textureWidth; s++)
            {
                Color[] colors = new Color[textureHeight];
                for (int v = 0; v < textureHeight; v++)
                {
                    colors[v] = HSVUtil.ConvertHsvToRgb(h, (float)s / textureWidth, (float)v / textureHeight, 1);
                }
                texture.SetPixels(s, 0, 1, textureHeight, colors);
            }
            texture.Apply();

            image.texture = texture;
        }
        private void RegenerateTexture()
        {
            Color32 baseColor = colorPicker != null ? colorPicker.Color : Color.black;

            float h = colorPicker != null ? colorPicker.H : 0;
            float s = colorPicker != null ? colorPicker.S : 0;
            float v = colorPicker != null ? colorPicker.V : 0;

            Texture2D texture;

            Color32[] colors;

            bool vertical = direction == Slider.Direction.BottomToTop || direction == Slider.Direction.TopToBottom;
            bool inverted = direction == Slider.Direction.TopToBottom || direction == Slider.Direction.RightToLeft;

            int size;

            switch (type)
            {
            case ColorValues.R:
            case ColorValues.G:
            case ColorValues.B:
            case ColorValues.A:
                size = 255;
                break;

            case ColorValues.Hue:
                size = 360;
                break;

            case ColorValues.Saturation:
            case ColorValues.Value:
                size = 100;
                break;

            default:
                throw new System.NotImplementedException("");
            }
            if (vertical)
            {
                texture = new Texture2D(1, size);
            }
            else
            {
                texture = new Texture2D(size, 1);
            }

            texture.hideFlags = HideFlags.DontSave;
            texture.wrapMode  = TextureWrapMode.Clamp;
            colors            = new Color32[size];

            switch (type)
            {
            case ColorValues.R:
                for (byte i = 0; i < size; i++)
                {
                    colors[inverted ? size - 1 - i : i] = new Color32(i, baseColor.g, baseColor.b, 255);
                }
                break;

            case ColorValues.G:
                for (byte i = 0; i < size; i++)
                {
                    colors[inverted ? size - 1 - i : i] = new Color32(baseColor.r, i, baseColor.b, 255);
                }
                break;

            case ColorValues.B:
                for (byte i = 0; i < size; i++)
                {
                    colors[inverted ? size - 1 - i : i] = new Color32(baseColor.r, baseColor.g, i, 255);
                }
                break;

            case ColorValues.A:
                for (byte i = 0; i < size; i++)
                {
                    colors[inverted ? size - 1 - i : i] = new Color32(i, i, i, 255);
                }
                break;

            case ColorValues.Hue:
                for (int i = 0; i < size; i++)
                {
                    colors[inverted ? size - 1 - i : i] = HSVUtil.ConvertHsvToRgb(i, 1, 1, 1);
                }
                break;

            case ColorValues.Saturation:
                for (int i = 0; i < size; i++)
                {
                    colors[inverted ? size - 1 - i : i] = HSVUtil.ConvertHsvToRgb(h * 360, (float)i / size, v, 1);
                }
                break;

            case ColorValues.Value:
                for (int i = 0; i < size; i++)
                {
                    colors[inverted ? size - 1 - i : i] = HSVUtil.ConvertHsvToRgb(h * 360, s, (float)i / size, 1);
                }
                break;

            default:
                throw new System.NotImplementedException("");
            }
            texture.SetPixels32(colors);
            texture.Apply();

            if (image.texture != null)
            {
                DestroyImmediate(image.texture);
            }

            image.texture = texture;

            switch (direction)
            {
            case Slider.Direction.BottomToTop:
            case Slider.Direction.TopToBottom:
                image.uvRect = new Rect(0, 0, 2, 1);
                break;

            case Slider.Direction.LeftToRight:
            case Slider.Direction.RightToLeft:
                image.uvRect = new Rect(0, 0, 1, 2);
                break;

            default:
                break;
            }
        }
        private void HSVChanged()
        {
            Color color = HSVUtil.ConvertHsvToRgb(hue * 360, saturation, brightness, this.color.a);

            this.color = color;
        }