the idea is that each level has it own color and that it lerps from one level to the other one.
old :
my script witch lerps between 2 colors every level (for 10 levels long) but it does not change very smooth. it has to change consistently thrue out the level bet each time it changes its a quite big color difference.
new :
when it lerps the color change is seamless but it does not always lerp because it does not always the exact color because of the lerping
edit: new code.
this is the script (you do need to change the colors manually so you can see the difference)
using UnityEngine;
using System.Collections;
public class ColorChanger : MonoBehaviour {
public Color ambColor1 = Color.red;
public Color ambColor2 = Color.blue;
public Color fogColor1 = Color.red;
public Color fogColor2 = Color.blue;
public float duration = 1.0F;
public Color fogColor3 = Color.blue;
public Color fogColor4 = Color.blue;
public Color fogColor5 = Color.blue;
public Color fogColor6 = Color.blue;
public Color fogColor7 = Color.blue;
public Color fogColor8 = Color.blue;
public Color fogColor9 = Color.blue;
public Color fogColor10 = Color.blue;
public Color fogColor11 = Color.blue;
public Color ambColor3 = Color.red;
public Color ambColor4 = Color.blue;
public Color ambColor5 = Color.red;
public Color ambColor6 = Color.blue;
public Color ambColor7 = Color.red;
public Color ambColor8 = Color.blue;
public Color ambColor9 = Color.red;
public Color ambColor10 = Color.blue;
public Color ambColor11 = Color.red;
public int map;
public bool LerpColorBool = true;
public GameObject DirectionalLight;
public GameObject levelManager;
// Use this for initialization
void Start () {
StartCoroutine (colorCheck ());
}
// Update is called once per frame
void Update () {
Debug.Log (ambColor1);
if (LerpColorBool == true)
{
LerpColor();
}
}
void LerpColor()
{
float t = Mathf.PingPong (Time.time, duration) / duration;
RenderSettings.fogColor = Color.Lerp (fogColor1, fogColor2, t);
RenderSettings.ambientLight = Color.Lerp (ambColor1, ambColor2, t);
DirectionalLight.light.color = Color.Lerp (ambColor1, ambColor2, t);
if (RenderSettings.fogColor == fogColor2) {
LerpColorBool = false;
}
}
IEnumerator colorCheck ()
{
yield return new WaitForSeconds(1f);
//LevelManager LM = levelManager.GetComponent<LevelManager> ();
if (LerpColorBool == false) {
map ++;
switch (map) {
case 1:
break;
case 2:
fogColor2 = fogColor3;
fogColor1 = fogColor2;
ambColor2 = ambColor3;
ambColor1 = ambColor1;
break;
case 3:
fogColor2 = fogColor3;
fogColor1 = fogColor4;
ambColor2 = ambColor3;
ambColor1 = ambColor4;
break;
case 4:
fogColor2 = fogColor4;
fogColor1 = fogColor5;
ambColor2 = ambColor4;
ambColor1 = ambColor5;
break;
case 5:
fogColor2 = fogColor5;
fogColor1 = fogColor6;
ambColor2 = ambColor5;
ambColor1 = ambColor6;
break;
case 6:
fogColor2 = fogColor6;
fogColor1 = fogColor7;
ambColor2 = ambColor6;
ambColor1 = ambColor7;
break;
case 7:
fogColor2 = fogColor7;
fogColor1 = fogColor8;
ambColor2 = ambColor7;
ambColor1 = ambColor8;
break;
case 8:
fogColor2 = fogColor9;
fogColor1 = fogColor8;
ambColor2 = ambColor9;
ambColor1 = ambColor8;
break;
case 9:
fogColor2 = fogColor9;
fogColor1 = fogColor10;
ambColor2 = ambColor9;
ambColor1 = ambColor10;
break;
case 10:
fogColor2 = fogColor11;
fogColor1 = fogColor10;
ambColor2 = ambColor11;
ambColor1 = ambColor10;
break;
}
LerpColorBool = true;
}
StartCoroutine (colorCheck ());
}
}