Created
November 27, 2017 22:14
-
-
Save yagero/42dec2690c6975ff471c7f9fb054964d to your computer and use it in GitHub Desktop.
Simple struct to save and restore Unity's fog properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public struct FogProperties | |
{ | |
public float EndDistance; | |
public float StartDistance; | |
public float Density; | |
public Color Color; | |
public FogMode Mode; | |
public bool Enabled; | |
public static FogProperties NewFromRenderSettings() | |
{ | |
var props = new FogProperties(); | |
props.EndDistance = RenderSettings.fogEndDistance; | |
props.StartDistance = RenderSettings.fogStartDistance; | |
props.Density = RenderSettings.fogDensity; | |
props.Color = RenderSettings.fogColor; | |
props.Mode = RenderSettings.fogMode; | |
props.Enabled = RenderSettings.fog; | |
return props; | |
} | |
public void ApplyToRenderSettings() | |
{ | |
RenderSettings.fogEndDistance = EndDistance; | |
RenderSettings.fogStartDistance = StartDistance; | |
RenderSettings.fogDensity = Density; | |
RenderSettings.fogColor = Color; | |
RenderSettings.fogMode = Mode; | |
RenderSettings.fog = Enabled; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment