I keep getting this error after attempting to assign my 2D Sprite’s Color. What exactly does it mean? Is it some sort of issue with the values? They do range from 0-255 which to my knowledge are the highest/lowest values color can go.
void Awake(){
GetComponent<SpriteRenderer>().color = new Color(Random.Range(0, 255),Random.Range(0, 255),Random.Range(0, 255), 255);
}
Generally, yes, color values range from 0 to 255. This is because 255 is the largest number possible using 8 bits, that way if your texture format is something like RGB24 or RGB32, you can use 3 or 4 color channels. Everything works out great.
This is far from an absolute, in Unity and many other applications, the Color structure is made of 4 floating point values ranging from 0 to 1. I would guess this makes passing around color values much easier for the engine.
So in your case, you just need to divide each of your values by 255 so they are in the range from 0 to 1.