How to run my CS function at a specific pass ?

Hello,
I’ve digged around the web and I havn’t found a clear example of what I’m trying to achieve.

Say this picture with all the passes from HDRP that can be found in the doc here Redirecting to latest version of com.unity.render-pipelines.high-definition

Say my CS script function

using UnityEngine;

public class MainCamera : MonoBehaviour {

    void OnPreCull () {
        Debug.Log("This function was called on the specific pass");
    }
}

OnPreCull doesn’t work anymore as said here Feedback Wanted: Scriptable Render Pipelines page-8#post-3408481

How can I let’s say inject my code on “BeforeRendering” like :

using UnityEngine;

public class MainCamera : MonoBehaviour {

    void BeforeRendering() {
        Debug.Log("This function was called on the specific pass");
    }
}

Is there a way to run my CS function at a certain point of the HDRP passes ?
I tryed to use the custom pass script, but it seem to require a material, and it was pretty obscure, I just want my CS function to run at a certain point.

Thank you for any answers !

I do tried to make a custom pass :

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

public class CustomPassPortal : CustomPass
{
    public MainCamera mc;

    protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd) { }

    protected override void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera camera, CullingResults cullingResult) {
        mc.debugBeforeRendering();
    }

    protected override void Cleanup() { }
}

The idea was to trigger my camera debugBeforeRendering function.
But the script inside the Execute function of the CustomPassPortal class is never called.
And I do not know why…

Restarting the scene seemed to do the trick.