Last active
July 20, 2022 11:37
-
-
Save paulhayes/9e4f2251887a10f56394 to your computer and use it in GitHub Desktop.
Extension to Unity3d Color and Color32. Allows easy converting of Color to hex string.
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
using UnityEngine; | |
using System.Collections; | |
public static class ColorExt { | |
public static string ToHexString(this Color32 c){ | |
return string.Format ("{0:X2}{1:X2}{2:X2}", c.r, c.g, c.b); | |
} | |
public static string ToHexString(this Color color){ | |
Color32 c = color; | |
return c.ToHexString(); | |
} | |
public static int ToHex(this Color32 c){ | |
return (c.r<<16)|(c.g<<8)|(c.b); | |
} | |
public static int ToHex(this Color color){ | |
Color32 c = color; | |
return c.ToHex(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment