Пример #1
0
        void DrawHexComponents()
        {
            byte a   = (byte)(int)(currentColor.a * 255);
            int  hex = PWColor.ColorToHex(currentColor, false);            //get color without alpha

            EditorGUIUtility.labelWidth = 80;
            EditorGUI.BeginChangeCheck();
            string hexColor = EditorGUILayout.TextField("Hex color", hex.ToString("X6"));

            if (EditorGUI.EndChangeCheck())
            {
                a = 255;
            }
            EditorGUIUtility.labelWidth = 0;
            Regex reg = new Regex(@"[^A-F0-9 -]");

            hexColor = reg.Replace(hexColor, "");
            hexColor = hexColor.Substring(0, Mathf.Min(hexColor.Length, 6));
            if (hexColor == "")
            {
                hexColor = "0";
            }
            hex          = int.Parse(a.ToString("X2") + hexColor, System.Globalization.NumberStyles.HexNumber);
            currentColor = (SerializableColor)PWColor.HexToColor(hex, false);
        }
Пример #2
0
        void DrawRGBComponents()
        {
            byte r, g, b, a;

            PWColor.ColorToByte(currentColor, out r, out g, out b, out a);
            EditorGUIUtility.labelWidth = 20;
            r            = (byte)EditorGUILayout.IntSlider("R", r, 0, 255);
            g            = (byte)EditorGUILayout.IntSlider("G", g, 0, 255);
            b            = (byte)EditorGUILayout.IntSlider("B", b, 0, 255);
            a            = (byte)EditorGUILayout.IntSlider("A", a, 0, 255);
            currentColor = (SerializableColor)PWColor.ByteToColor(r, g, b, a);
            EditorGUIUtility.labelWidth = 0;
        }