mantain color brightness and change only hue

Hello everyone!
I have a self illuminated material. I want to change its hue value but keep its brightness always at the same value at runtime. I attach the color scheme to better explain myself: i need the white circle to stay always at that position and only the color slider on the right to go up and down over time, choosing random values every bunch of seconds. How can i code this?

6662-colors.jpg

There are several snippets of code on the web for HSL translations. Typically they are called TransformHSL or TransformHSV. When I needed to do an HSL translation I based my code on the information and sample code (towards the bottom) in this web page: HSV color transforms

You just need to manipulate with hue value in a HSV color model and then convert the color to RGB.

You can find some conversion scripts for that

If you want this for the Color chooser in the Editor, just click on the little striped square just above the 4 numbers seen in your snapshot, then the sliders change to HSV.

To do this via script, you’ll need a RGB<->HSV conversion, for example here: http://pastebin.com/A16q3tbU

EDIT: woops, I see @tomekkie2 already answered this, but as a comment.

hi there, old post, but if anyone is wondering how to do a hue slider, use this (js):

public var SkyColor : Color = Color.white;
public var hSliderValue : float = 120.0;
public var cSliderValue : float = 0;

function Update() {
SkyColor = EditorGUIUtility.HSVToRGB(cSliderValue/360,hSliderValue/180,1);
}
function OnGUI() {
hSliderValue = GUI.HorizontalSlider (Rect (822, 196+(Mathf.Sin(hSliderValue*-.0175)*30), 243, 39), hSliderValue, 0.0, 180.0);
}

Here’s a nice package for easy HSV blending, which is what you’re looking for. Basically just change Color.Lerp() to Colorx.Slerp().

http://wiki.unity3d.com/index.php/Colorx