Пример #1
0
        void Awake()
        {
            // if a default color picker texture hasn't been assigned, make one dynamically
            if (!colorPicker)
            {
                colorPicker = new Texture2D(textureWidth, textureHeight, TextureFormat.ARGB32, false);
                ColorHSV hsvColor;
                for (int i = 0; i < textureWidth; i++)
                {
                    for (int j = 0; j < textureHeight; j++)
                    {
//					hsvColor = new ColorHSV((float)i, (1.0f / j) * textureHeight, 1.0f);
                        hsvColor = new ColorHSV((float)i, (1.0f / j) * textureHeight, 1.0f);
                        colorPicker.SetPixel(i, j, hsvColor.ToColor());
                    }
                }
            }
            colorPicker.Apply();
            displayPicker = colorPicker;

            if (!useDefinedSize)
            {
                textureWidth  = colorPicker.width;
                textureHeight = colorPicker.height;
            }

            float v    = 0.0F;
            float diff = 1.0f / textureHeight;

            saturationTexture = new Texture2D(20, textureHeight);
            for (int i = 0; i < saturationTexture.width; i++)
            {
                for (int j = 0; j < saturationTexture.height; j++)
                {
                    saturationTexture.SetPixel(i, j, new Color(v, v, v));
                    v += diff;
                }
                v = 0.0F;
            }
            saturationTexture.Apply();

            // small color picker box texture
            styleTexture = new Texture2D(1, 1);
            styleTexture.SetPixel(0, 0, setColor);
        }
Пример #2
0
        public static Color GetRandomColor(float h, float s, float v)
        {
            ColorHSV col = new ColorHSV(h, s, v);

            return(col.ToColor());
        }