Search Unity

new Color.HSVToRGB and Color.RGBToHSV methods!

Discussion in 'General Graphics' started by Oscaruzzo, Dec 14, 2015.

  1. Oscaruzzo

    Oscaruzzo

    Joined:
    Jan 26, 2015
    Posts:
    17
    Well it looks like Unity 5.3 has (finally) added two new static methods on the Color class to convert to and from RGB and HSV. These were previously in EditorGUIUtility which is in the UnityEditor namespace, making them unusable in deployment.

    This is great, especially when you need to interpolate between two colors and you want to have constant saturation and value and just change the hue.

    This is the 5.2.0 docs (without these methods) http://docs.unity3d.com/520/Documentation/ScriptReference/Color.html

    And this is the 5.3.0 docs (with the new methods) http://docs.unity3d.com/530/Documentation/ScriptReference/Color.html

    BTW I couldn't find any mention of this in the release note. I found it by chance. So I'm just letting anybody know :D

    Also an HSVLerp method could be useful ;)
     
  2. sanmn19

    sanmn19

    Joined:
    Jun 30, 2013
    Posts:
    56
    Yeah. Finally! I used the HSVToRGB method and when I provided the value of H greater than 1, the returned r,g,b was 0, 0, 0. I would generally expecting it to clamp to 1 and return the r,g,b value.