示例#1
0
    public static bool HexaKeyToColor(string hexaKey, out Color color)
    {
        bool result = true;

        color = Color.white;
        bool flag = true;

        for (int i = 1; i < 7; i++)
        {
            if (AgeUtils.ValidHex.IndexOf(hexaKey[i]) < 0)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            color.r = (AgeUtils.ComputeHexa(hexaKey[1]) * 16f + AgeUtils.ComputeHexa(hexaKey[2])) / 255f;
            color.g = (AgeUtils.ComputeHexa(hexaKey[3]) * 16f + AgeUtils.ComputeHexa(hexaKey[4])) / 255f;
            color.b = (AgeUtils.ComputeHexa(hexaKey[5]) * 16f + AgeUtils.ComputeHexa(hexaKey[6])) / 255f;
        }
        else
        {
            result = false;
        }
        return(result);
    }