I added 8 light probes in my scene as a test.
During run-time, I want to toggle some light probes on/off. (Those light probes act as night-time lights and I want them off during the day).
So, it seems like I cannot assign to LightmapSettings.lightProbes.bakedProbes even though it looks like I should be able to,
So, I thought of assigning to LightmapSettings.lightProbes instead, but I cannot do that because there is no accessible constructor for LightProbes.
I don’t want to loop over all dynamic renderers and set their light probe usage to “Off”.
I just want to modify the LightmapSettings directly.
Disabling the Light Probe Group component or game object does not do anything during run-time.
[EDIT]
Just noticed I’m getting this warning:
Trying to set 0 coefficients, but number of probes is 8.
I haven’t tested light probes in multiple scenes, loaded additively, but I assume Unity is somehow able to modify the number of probes as I dynamically load and unload scenes.
There is logic in place to prevent writing an incorrect amount of SphericalHarmonicsL2 to that array. IIRC if you write too few, the missing ones will be ignored and those positions will be unchanged in the array, and if you write too many, they will be truncated.
Loading and unloading probe sets is primarily supported via additive scene loading. When you load a scene with probes additively, those probes will get appended to global structure in LightmapSettings.lightProbes (remember to call Lightmapping.Tetrahedralize(), though). The same goes for unloading scenes.
For your use case, I would either:
Set the bakedProbes array to an array of fully-black SH coefficients with the correct size
Swap out the entire Lightmapping.lightProbes object with a different one.
Use additive scene loading and have a few additive scenes for each configuration of baked lighting
The reason you can’t just add or remove probes like that, is that all the probes are put into large global data structure for efficient sampling. Manipulation of this structure is unfortunately not exposed to users in any particularly sensible way. This is likely to improve in the future.
I wonder why you design probe in such a disgusting way. All the game makers are trying to dynamic load/unload game object with lightmaps yet the probes are unable to do that