Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class WorldFadeFog : MonoBehaviour {
- public Color32 fogColour;
- public float fadeStart = 10f;
- public float fadeEnd = 1000f;
- public float transitionTime = 4.0f;
- public IEnumerator Trigger () {
- float t = 0;
- Color startFog = RenderSettings.fogColor;
- float startFogStart = RenderSettings.fogStartDistance;
- float startFogEnd = RenderSettings.fogEndDistance;
- while (t < transitionTime) {
- // color
- RenderSettings.fogColor = new Color(Mathf.Lerp(startFog.r, fogColour.r/255.0f, t / transitionTime),
- Mathf.Lerp(startFog.g, fogColour.g/255.0f, t / transitionTime),
- Mathf.Lerp(startFog.b, fogColour.b/255.0f, t / transitionTime));
- // fog start and end
- RenderSettings.fogStartDistance = Mathf.Lerp(startFogStart, fadeStart, t / transitionTime);
- RenderSettings.fogEndDistance = Mathf.Lerp(startFogEnd, fadeEnd, t / transitionTime);
- t += Time.deltaTime;
- Debug.Log(t / transitionTime);
- yield return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement