How to Use HSBColor script?


I am trying to change the color of the object(it is a child object) via this script in this link: HSBColor Wiki but i couldn’t call what i need to call to change color of my object in that script. I’ve just did that in my own script:

public HSBColor hsbcolor;

void Example()
      this.transform.FindChild ("Graphics").GetComponent<SpriteRenderer> ().color = new HSBColor(new Color(1f, 2f, 3f, 1f);

Something is wrong in this code, i couldn’t find what it is. I get error when i use this.

How can i call HSBColor function from script in link? Or what should i add after equal sign?

You have a few issues here. I’m guessing that you want to specify an HSBColor and assign the result to color the sprite. So you first have to produce an HSBColor struct with the right values, then you have to convert the result to a Color to be able to assign it. Untested:

  transform.FindChild ("Graphics").GetComponent<SpriteRenderer> ().color = HSBColor.ToColor(new HSBColor(0.333,0.0f,0.5f,0.5f,1.0f));

When you dont need HSB, than try this:

		transform.FindChild ("Graphics").GetComponent<SpriteRenderer> ().color = new Color32(40,10,30,100);
		//or this
		transform.FindChild ("Graphics").GetComponent<SpriteRenderer> ().color = new Color(0.4f,0.1f,0,0.7f);