As a reminder for me and others:
Starting with Unity 2032.2 (or more precisely CoreRP Library 16.0.6) the VolumeMananger is initialized late (meaning after frame 1). This means that registering custom Volumes will FAIL SILENTLY and you may wonder why your volumes have no effect. To make them have any effect you have to wait until the VolumeManager is ready to receive input (aka check isInitialized).
Here is some code:
#if UNITY_2023_2_OR_NEWER
// Starting with Unity 2023.2.0 the VolumeManager needs to be initialized.
// Sadly this is done only AFTER the very first frame of the game was rendered.
// Therefore, to make the VolumeManager aware of THIS volume we have to register it
// as soon as the manager has been initialized.
[System.NonSerialized]
protected bool _volumeWasRegisteredWithMananger = false;
public void Update()
{
if (!_volumeWasRegisteredWithMananger && VolumeManager.instance.isInitialized)
{
_volumeWasRegisteredWithMananger = true;
unregisterFromVolumeMananger(Volume, Camera.main.gameObject.layer);
registerWithVolumeMananger(Volume, Camera.main.gameObject.layer);
}
}
#endif
// And there is also some Unity 6 fun to be had Oo.
private static void registerWithVolumeMananger(Volume volume, int layer)
{
#if UNITY_6000_0_OR_NEWER
VolumeManager.instance.Register(volume);
#else
VolumeManager.instance.Register(volume, layer);
#endif
}
private static void unregisterFromVolumeMananger(Volume volume, int layer)
{
#if UNITY_6000_0_OR_NEWER
VolumeManager.instance.Unregister(volume);
#else
VolumeManager.instance.Unregister(volume, layer);
#endif
}
Why it does not at least log a warning if a volume is registered before it is initialzed is beyond me. Especially frustrating since Unity introduced this breaking change in a MINOR version (2023.1. = all good, 2023.2+ = new silent failing behaviour).