Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class WorldFadeFog : MonoBehaviour {
  5.  
  6. public Color32 fogColour;
  7. public float fadeStart = 10f;
  8. public float fadeEnd = 1000f;
  9.  
  10. public float transitionTime = 4.0f;
  11.  
  12.  
  13.  
  14.  
  15. public IEnumerator Trigger () {
  16.  
  17. float t = 0;
  18. Color startFog = RenderSettings.fogColor;
  19. float startFogStart = RenderSettings.fogStartDistance;
  20. float startFogEnd = RenderSettings.fogEndDistance;
  21.  
  22. while (t < transitionTime) {
  23.  
  24. // color
  25. RenderSettings.fogColor = new Color(Mathf.Lerp(startFog.r, fogColour.r/255.0f, t / transitionTime),
  26. Mathf.Lerp(startFog.g, fogColour.g/255.0f, t / transitionTime),
  27. Mathf.Lerp(startFog.b, fogColour.b/255.0f, t / transitionTime));
  28.  
  29. // fog start and end
  30. RenderSettings.fogStartDistance = Mathf.Lerp(startFogStart, fadeStart, t / transitionTime);
  31. RenderSettings.fogEndDistance = Mathf.Lerp(startFogEnd, fadeEnd, t / transitionTime);
  32.  
  33. t += Time.deltaTime;
  34. Debug.Log(t / transitionTime);
  35.  
  36.  
  37. yield return null;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement