Skip to content

Scripting API

Instantiate a new Volumetric Light Beam

To create a new Volumetric Light Beam programmatically, simply add the VLB.VolumetricLightBeam component to a new GameObject:

var myBeam = new GameObject("MyBeam", typeof(VLB.VolumetricLightBeam));

or to an existing one:

GameObject myGAO = ...
var myBeam = myGAO.AddComponent<VLB.VolumetricLightBeam>();

Enabling / Disabling

The Volumetric Light Beam enabling/disabling mechanism has been designed the same way Unity handles Lights: using the enabled property.
If you want to turn on/off only the beam from script, you can change the enabled property of the component:

var beam = GetComponent<VLB.VolumetricLightBeam>();
beam.enabled = false; // turn off the beam (and the beam only)

If a VolumetricLightBeam component is attached on the same GameObject than a Light, disabling the Light component will not disable the beam (the light and the beam are 2 distinct components).

Additionally you can turn on/off both the light and the beam, by simply set the GameObject active/inactive: gameObject.SetActive(false);

Modify properties at instantiation

You can edit and modify any properties of a Volumetric Light Beam just after instantiating by code. For example, the following code adds a new beam, changes its colors, enables and tweaks the 3D Noise feature on it:

var beam = myGAO.AddComponent<VLB.VolumetricLightBeam>();
beam.color =;
beam.noiseMode = VLB.NoiseMode.WorldSpace;
beam.noiseIntensity = 0.75;
beam.noiseScaleUseGlobal = false;
beam.noiseScaleLocal = 0.6;

Modify properties during playtime

If you want to modify the beam's properties via Script during runtime/playtime, you have to either:

  • call UpdateAfterManualPropertyChange:
var beam = myGAO.GetComponent<VLB.VolumetricLightBeam>();
beam.fallOffEnd = Time.time * 0.1f;
beam.color =;
beam.UpdateAfterManualPropertyChange(); // take the changes into account
  • or call GenerateGeometry if your beam uses a custom mesh (geomMeshType == VLB.MeshType.Custom) and you have changed geomCustomSides and/or geomCustomSegments properties:
var beam = myGAO.GetComponent<VLB.VolumetricLightBeam>();
beam.color =;
beam.geomMeshType = VLB.MeshType.Custom;
beam.geomCustomSides = 32;
beam.geomCustomSegments = 4;
beam.GenerateGeometry(); // call GenerateGeometry instead of UpdateAfterManualPropertyChange because geomCustomSides and geomCustomSegments has been modified

Additionally, if you want to change the beam's properties during playtime without having to call a function manually (for example if you want to animate a beam via an Animator or a Timeline), you can simply enable the trackChangesDuringPlaytime property at a minor performance cost.