Accessing properties
All properties shown in the inspector are accessible through the volumetric light component.
First you need to get a reference to the main script which can be done easily using:
using VolumetricLights;
…
VolumetricLight vl = lightGameObject.GetComponent<VolumetricLight>;
(where lightGameObject is the gameobject of the light)
Then, you can set any property like density or wind speed/direction:
vl.density = 0.2f;
vl.windDirection = Vector3.right;
etc.
Call vl.UpdateMaterialProperties() to issue a refresh after setting the new values.
Creating volumetric lights at runtime
Use this code to create a new volumetric light using code:
VolumetricLight vl = lightGameObject.AddComponent<VolumetricLight>();
Volumetric Lights supports runtime parameter adjustments via C# scripting. When modifying properties through code, it’s essential to call the UpdateMaterialProperties() method to ensure that changes are correctly applied to the material and visual output.
// Example
volumetricLight.intensity = 2.5f;
volumetricLight.UpdateMaterialProperties();
This method refreshes the internal material settings, allowing dynamic updates to take effect immediately.