I am adding code to be able disable and enable post processing effects based on device levels.
I have not found anything built into the processing stack to make this easy.
So my scripts are enabled and disabling various parts of the PP Stack and Cinemeachine.
In order to actually remove all the command buffers from a camera when all the effects are turned off.
You have to disable the Post Process Layer.
I disable it in my scripts. But doing this on enable in my script is causing the PostProcessLayer::InitBundles to not be called. But the ResetHistory is being called every frame by Cinemachine Post Processing.
And in the case of the InitBundles not being called the m_Bundles is null and generates an exception.
There needs to be a null check there or by default m_Bundles should not be null and just an empty dictionary.
I am hoping I can work around it by disabling things over a frame or two giving the Initbundles a chance to be called.
public void ResetHistory()
{
foreach (var bundle in m_Bundles)
bundle.Value.ResetHistory();
temporalAntialiasing.ResetHistory();
}
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Rendering.PostProcessing.PostProcessLayer.ResetHistory () (at Library/PackageCache/com.unity.postprocessing@3.1.1/PostProcessing/Runtime/PostProcessLayer.cs:810)
Cinemachine.PostFX.CinemachinePostProcessing.OnCameraCut (Cinemachine.CinemachineBrain brain) (at Library/PackageCache/com.unity.cinemachine@2.7.8/Runtime/PostProcessing/CinemachinePostProcessing.cs:223)
UnityEngine.Events.InvokableCall1[T1].Invoke (T1 args0) (at <9899854e5b05425ab27d31f737cde095>:0) UnityEngine.Events.UnityEvent1[T0].Invoke (T0 arg0) (at <9899854e5b05425ab27d31f737cde095>:0)
Cinemachine.CinemachineBrain.ProcessActiveCamera (System.Single deltaTime) (at Library/PackageCache/com.unity.cinemachine@2.7.8/Runtime/Behaviours/CinemachineBrain.cs:618)
Cinemachine.CinemachineBrain.ManualUpdate () (at Library/PackageCache/com.unity.cinemachine@2.7.8/Runtime/Behaviours/CinemachineBrain.cs:368)
Cinemachine.CinemachineBrain.LateUpdate () (at Library/PackageCache/com.unity.cinemachine@2.7.8/Runtime/Behaviours/CinemachineBrain.cs:325)