HexConverter

JavaScript
function GetHex (decimal : int) : String Converts int between 0 and 15 to hexidecimal character. function HexToInt (hexChar : char) : int Converts single hexadecimal character (0..F) to the corresponding int. function RGBToHex (color : Color) : String Convert a Unity color to hexadecimal. NOTE: this function assumes that color values are in the 0..1 range. Alpha values are ignored. function HexToRGB (color : String) : Color Convert standard web-formatted (hexadecimal) color (000000..FFFFFF) to RGB color with values in 0..1 range.

Author: Danny Lawrence

JavaScript Redux
Author: yoyo

Note that the approach suggested below by mvi can also be applied in JavaScript, for example:

C#
Author: mvi