HSV to RGB

I am trying to have the camera background color cycle over time by changing the Hue value each frame.
I found a script for HSVToRGB but it isn’t quite working as the background just shows up black no matter what values i put in.

#pragma strict
var cam : Camera;
var Hcol : float;
var Scol : float;
var Vcol : float;

function Start () 
{
	
}

function FixedUpdate () 
{
	
	cam.backgroundColor = HSVtoRGB(Hcol,Scol,Vcol);
}

function HSVtoRGB(h : float, s : float, v : float) 
{
	h=h%1;
	s=s%1;
	v=v%1;
	var r : float;
	var g : float;
	var b : float;
	var i : float;
	var f : float;
	var p : float;
	var q : float;
	var t : float; 
	i = Mathf.Floor(h * 6);
	f = h * 6 - i;
	p = v * (1 - s);
	q = v * (1 - f * s);
	t = v * (1 - (1 - f) * s);
	switch (i % 6) 
	{
	case 0: r = v; g = t; b = p; break;
	case 1: r = q; g = v; b = p; break;
	case 2: r = p; g = v; b = t; break;
	case 3: r = p; g = q; b = v; break;
	case 4: r = t; g = p; b = v; break;
	case 5: r = v; g = p; b = q; break;
	}
	return Color(r,g,b); 
}

No errors appear when i run the game, the values for Hue, Saturation, and Value just all go to zero making the background black. I would like Hue to be zero but saturation to be 150 and value to be 90.

Thank you for any help

I’d say the first 3 lines should be

h=h >= 0 ? h % 1 : 1 - (-h % 1);
s=Mathf.Max(0, Mathf.Min(1, s));
v=Mathf.Max(0, Mathf.Max(1,v));

These lines let you safely adjust h, s, and v without worrying about them going out of range. Kind of like Mathf.sin doesn’t go out of range.

Otherwise my guess is the switch isn’t happy using a float?

Try changing i to an int

 var i : int;