public static HSVColor RGBToHSV(Color color) { HSVColor ret = new HSVColor(0f, 0f, 0f, color.a); float r = color.r; float g = color.g; float v = color.b; float max = Mathf.Max(r, Mathf.Max(g, v)); if (max <= 0f) { return(ret); } float min = Mathf.Min(r, Mathf.Min(g, v)); float dif = max - min; if (max > min) { if (WadeUtils.AreEqual(g, max)) { ret.h = (v - r) / dif * 60f + 120f; } else if (WadeUtils.AreEqual(v, max)) { ret.h = (r - g) / dif * 60f + 240f; } else if (v > g) { ret.h = (g - v) / dif * 60f + 360f; } else { ret.h = (g - v) / dif * 60f; } if (WadeUtils.IsNegative(ret.h)) { ret.h = ret.h + 360f; } } else { ret.h = 0f; } ret.h *= 1f / 360f; ret.s = (dif / max) * 1f; ret.v = max; return(ret); }