A simple C# script that allows for creating UnityEngine Color32 variables via a hex code string
Getting ColorHex into your Unity project is as simple as dropping the ColorHex.cs file into your Assets/Scripts
project folder.
In order to have access to ColorHex in your script, make sure to include using ColorHexUtility;
at the top of any script that requires it.
Instead of using Color32's constructor which requires you to pass byte values, you can now use the ColorHex constructor to pass in a hex code string. Since ColorHex is designed to be interoperable with Color32, an implementation can look like this:
public Color32 tintRed500 = new ColorHex("#F14234");
- Reduces development time (and headaches) by letting you use a color code that can be copy-pasted straight from programs like Photoshop
- Works with or without a preceding '#' character
- Supports alpha values (ex. #FFFFFF00)
- Allows some text editor/IDE plugins to preview your color (ex. Color Info for Visual Studio Code