Created
December 23, 2025 00:42
-
-
Save hariedo/74dd85063efb54c01a4ac97df3a39916 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
| // UnityColorUtilities.cs | |
| // | |
| using UnityEngine; | |
| public static class ColorUtilities | |
| { | |
| public static Color HexRGB(uint hexcode) | |
| { | |
| // e.g., 0xFF0033 | |
| float b = (hexcode & 0xFF) / 255f; | |
| float g = ((hexcode >> 8) & 0xFF) / 255f; | |
| float r = ((hexcode >> 16) & 0xFF) / 255f; | |
| return new Color(r, g, b); | |
| } | |
| public static Color HexRGBA(uint hexcode) | |
| { | |
| // e.g., 0xFF003380 | |
| float a = (hexcode & 0xFF) / 255f; | |
| float b = ((hexcode >> 8) & 0xFF) / 255f; | |
| float g = ((hexcode >> 16) & 0xFF) / 255f; | |
| float r = ((hexcode >> 24) & 0xFF) / 255f; | |
| return new Color(r, g, b, a); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment