Accessing global fog properties
All properties shown in the inspector can be set or modified at runtime using scripting.
First you need to get a reference to the main script which can be done easily using:
DynamicFog fog = dynamicFogVolume.GetComponent<DynamicFog>;
(where dynamicFogVolume is the gameobject of the fog volume)
Then, you can set any property like the fog color or wind speed/direction:
fog.profile.color = new Color(1,0,0); fog.profile.windDirection = Vector3.right;
Creating fog volumes at runtime
Use this code to create a new fog volume using code:
GameObject fogVolume = DynamicFogManager.CreateFogVolume(“New Fog Volume”);
Fog of War methods
The following fog of war methods are available:
Property that returns or set the fog of war texture.
General reset function which removes any previous change to fog of war transparency.
Restores fog immediately at a given position with radius or bounds.
Returns the opacity of the fog at a given world position.
Changes the transparency of the fog in an area. This method is overloaded and can accept different paremeters and options:
A world position and a radius, or a bounds object or a world position and size.
Desired alpha and specify if this value replaces the existing transparency or if it blends with it (blendAlpha parameter).
The duration of the transition (pass 0 to set the alpha immediately).
The smoothness/harshness of the border (by default it uses the global setting in Fog Of War section which is 1f).
The restore delay and duration (by default it uses the global settings in Fog Of War section). Pass 0 to restore delay to make the change permanent.