Converting Hex colors to FColor using built-in capabilities erroneous.

Oh, ok I can see some problems with your latter original examples. The first two should be fine though, the second is weird as you are ‘dereferencing’ the string to pass a char array, but FromHex() only takes an FString so it is just being implicitly convert back. Both should work though (and should have in the example you originally supplied).

The third is correct, the double deref means you are effectively passing the first char into HexDigit(), in this case ‘#’, which is not a Hexadecimal digit in which case 0 is returned.

Fourth is also correct, this time passing ‘F’ into HexDigit() gives back 15, which you then construct a color with (constructing with an int will just set the 32 bits raw, so the format is actually ARGB).

So the 5th and 6th are correct for the same reason (the int construction, and therefor ARGB format).

1 Like