How to bake Adaptive Probe Volume by Editor script

So, I have level design generator. And my level design production pipeline is simple. Now I need to automate (add logic to my current editor script) this logic: Open lighting tab, set mode to “Baking set” → selecting game object that holds all level design elements->in APV press “Fit to Selection”-> press Bake . Can someone tell me public static methods to automate this process?

There’s AdaptiveProbeVolumes.BakeAsync() to kick off a bake of just APV, or Lightmapping.BakeAsync() to bake everything. ProbeReferenceVolume.instance.SetActiveBakingSet() can be used to set the current baking set.

You can configure the size of the probe volume using ProbeVolume.size and ProbeVolume.transform.position. I’m afraid there’s no way to “fit to selection” from script, but you can check how it’s done in ProbeVolumeUI.Drawer_BakeToolBar.

ProbeVolumeBakingSet is a scriptable object, so you can create a new instance of it using ScriptableObject.CreateInstance().

Hope some of that helps.

Is there an equivalent event callback for when APV starts/finishes baking like there is for the Lightmapper?

As if you bake just the probe volumes via Lighting > Adaptive Probe Volumes > Bake Probe Volumes then these two events are never called

Lightmapping.bakeStarted += OnBakeStarted;
Lightmapping.bakeCompleted += OnBakeCompleted;

ProbeVolumeFitToSceneController has required controllers to batch, listen etc. I managed to fully automate baking APV with it on 6000.0.33f1 it should be attached to same gameObject which holds APV

ProbeVolumeFitToSceneController.cs (70.0 KB)
ProbeVolumeFitToSceneControllerEditor.cs (13.9 KB)

There isn’t at the moment, closest you get is a boolean you can poll (AdaptiveProbeVolumes.isRunning). It’s not a bad idea, though. I’ll make a ticket to track it as a request.