Problems creating the Post Process Stack entirely from Code

I cannot seem to create the entire Post Process Stack via coding. I get lots of errors. I have followed the sporadic Answers online for modifiying the PPS via code but this doesnt really tell me much about how it works and the Unity documentation is awful for people who program software, as it relys heavily upon drag and drop development, so no luck there! sigh

I use no prefabs so answers such like “just drag it via the inspector” wont help as this is not useful for me as I do not use any prefabs whatsoever.

So far I have added a Layer to the camera and have an object with the Volume in it.
I am setting up everything correctly but…

My main issue seems to be I am unable to load a PP Profile into the Volume via code wether Resources.Load() is in Awake or Start()…It simply doesnt appear!
I had this issue months ago and gave up. Im sure my Resources Load path is correct!
Is there any reason why I shouldnt be able to Load the PPP via code?

This is my Error which is massivley unhelpful but as I mentioned my profile seems to be unable to be set at runtime so I assume this is the error.

I tried this a few months back and had the exact same issue!

Would be really helpful if somone else has tried to set this all up via code :stuck_out_tongue:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Rendering.PostProcessing.AmbientOcclusion.IsEnabledAndSupported (UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context) (at Library/PackageCache/com.unity.postprocessing@2.3.0/PostProcessing/Runtime/Effects/AmbientOcclusion.cs:182)
UnityEngine.Rendering.PostProcessing.PostProcessLayer.SetLegacyCameraFlags (UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context) (at Library/PackageCache/com.unity.postprocessing@2.3.0/PostProcessing/Runtime/PostProcessLayer.cs:771)
UnityEngine.Rendering.PostProcessing.PostProcessLayer.SetupContext (UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context) (at Library/PackageCache/com.unity.postprocessing@2.3.0/PostProcessing/Runtime/PostProcessLayer.cs:863)
UnityEngine.Rendering.PostProcessing.PostProcessLayer.BuildCommandBuffers () (at Library/PackageCache/com.unity.postprocessing@2.3.0/PostProcessing/Runtime/PostProcessLayer.cs:533)
UnityEngine.Rendering.PostProcessing.PostProcessLayer.OnPreCull () (at Library/PackageCache/com.unity.postprocessing@2.3.0/PostProcessing/Runtime/PostProcessLayer.cs:462)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Okay So i have fixed the issue with the Profile not loading. That was my bad… ( stupid “/”) but now I would like to know what is PostProcessResources and how do I call postProcessLayer.Init(postProcessResources);

when I dont know what PostProcessResources class is and when there is no documentation

Could somone explain exactly what I need to load into postProcessResources to get this to work as Unity seems to have left ANY documentation about exactly what this class is out… The best I found is :

Method :

Initializes this layer. If you create the layer via scripting you should always call this method.

public void Init(PostProcessResources resources)

PostProcessResources resources
A reference to the resource asset <<< What is this class. What does it do, and how do I make one as Unity seems to have forgotten about this!