Tag Info

New answers tagged

1

One approach that can be taken with multiple color transitions is to leverage a Gradient. By exposing a public variable of this type a developer an use the Inspector to launch the Gradient Editor to design a gradient containing any number of colors. This editor allows you to use a the unity color pickers, fine tune placement of the color/alpha keys and ...


9

let Arr be an array of Colour let N be the number of colors in the array let t be the 0..1 float value float scaledT = t* (float)(N-1); Color prevC = Arr[(int)scaledT]; Color nextC = Arr[(int)(scaledT+1f)]; float newt = scaledT - (float)((int)scaledT); finaly you can use Lerp Color.Lerp(prevC, nextC, newT)


0

How about you write your own version, which leverages Color.Lerp()? A very simple version that takes 3 colors, and puts the second one right in the middle could look like this: Color Lerp3(Color a, Color b, Color c, float t) { if (t < 0.5f) // 0.0 to 0.5 goes to a -> b return Color.Lerp(a, b, t / 0.5f); else // 0.5 to 1.0 goes to b ...


0

I feel like there may be a better solution. The only reason I would see to lerp from color to color is if you were wanting to continuously change the hue... http://en.wikipedia.org/wiki/Hue Here's how to convert HSV to RGB: http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSV With this you can use HSV colors, simply change the hue, then convert to RGB. ...


1

public float every; //The public variable "every" refers to "Lerp the color every X" float colorstep; Color[] colors = new Color[4]; //Insert how many colors you want to lerp between here, hard coded to 4 int i; Color lerpedColor = Color.red; //This should optimally be the color you are going to begin with void Start () { //In here, set the array ...



Top 50 recent answers are included