Last active
July 12, 2022 01:10
-
-
Save fiote/532c9274bb8b363d1d7e652b0861770c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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