Is there a way to simplify “RainbowFade” function? I’m just getting started with programming, and I’ve heard that using a lot of “else if” isn’t good.
I think this is better.

Okay that simplified the code a lot, only I have one question. How do you loop it infinite? actually the code looks like this.

Probably be easier to bit shift all of the values into a single integer and use a switch statement on it. That would simplify things quite a bit. Alternatively, you can also use hexadecimal to represent your colors as well. I’m not entirely sure how Unity’s framework represents colors though so don’t hold me to this, I’m too lazy to pull up the docs and I use my own engine.

By using HSV instead of RGB you can get this effect by ever increasing the Hue value. I would try to use some Color.HsvToRgb or something instead.

source