Skip to content

Instantly share code, notes, and snippets.

@fiote
Last active July 12, 2022 01:10
Show Gist options
  • Save fiote/532c9274bb8b363d1d7e652b0861770c to your computer and use it in GitHub Desktop.
Save fiote/532c9274bb8b363d1d7e652b0861770c to your computer and use it in GitHub Desktop.
static Dictionary<string, Color> cachedColors = new Dictionary<string, Color>();
public static Color GetColor(string hex) {
if (cachedColors.ContainsKey(hex)) return cachedColors[hex];
Color color;
ColorUtility.TryParseHtmlString(hex, out color);
cachedColors[hex] = color;
return color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment