using UnityEngine;

public class RandomColor : MonoBehaviour {

    public const float delayBetweenColors = 3f;

    private const float fps = 30f;

	void Start () {
        GameObject[] gos = FindObjectsOfType<GameObject>();
        for (int i = 0; i < gos.Length; i++) {
            if (gos[i].GetComponent<Renderer>() != null) {
                gos[i].AddComponent<ChangeColor>();
            }
        }
        InvokeRepeating("ChangeSkyFadeColor", 0, delayBetweenColors);
    }

    void ChangeSkyFadeColor() {
        RotateSkybox.skyboxMat.SetColor("_Tint", new Color(Random.value, Random.value, Random.value));
    }

    void OnApplicationQuit() {
        RotateSkybox.skyboxMat.SetColor("_Tint", new Color(0.5f, 0.5f, 0.5f));
    }
}