From 32684bc63e4d3ef2905ee072fd33e9b4875822f2 Mon Sep 17 00:00:00 2001 From: Sinai <49360850+sinai-dev@users.noreply.github.com> Date: Sun, 25 Oct 2020 21:28:58 +1100 Subject: [PATCH] Update ColorUtilityUnstrip.cs --- src/Unstrip/ColorUtility/ColorUtilityUnstrip.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Unstrip/ColorUtility/ColorUtilityUnstrip.cs b/src/Unstrip/ColorUtility/ColorUtilityUnstrip.cs index 8611c9a..8e950b5 100644 --- a/src/Unstrip/ColorUtility/ColorUtilityUnstrip.cs +++ b/src/Unstrip/ColorUtility/ColorUtilityUnstrip.cs @@ -10,14 +10,11 @@ namespace Explorer.Unstrip.ColorUtility { public static string ToHex(this Color color) { - var color32 = new Color32( - (byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255), - (byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255), - (byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255), - 1 - ); + var r = (byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255); + var g = (byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255); + var b = (byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255); - return string.Format("{0:X2}{1:X2}{2:X2}", color32.r, color32.g, color32.b); + return $"{r:X2}{g:X2}{b:X2}"; } } }