How do I access the renderer features of my UniversalRenderPipelineAsset via script?

I made a couple shaders + materials that I apply as post processing effects. Below is one called ‘scanlines’:

I would like to turn the scanlines on and off via script… depending on user preferences or gameplay situations. How can I access the renderer features and toggle them on/off or change their settings?

Thanks!

I did this using a Singleton. You can create one like explained here: Singleton Design Pattern In C#

In a nutshell: a class that instantiates itself and makes sure there is just one single copy of it. You can then add a public property to it that both the RendererFeature and the game code can use.

So to actually answer your question: You don’t access it. There could be multiple instances of the feature for the game and scene view around, among which you’d have to choose… so you turn the problem around and ask instead about something that both the renderer feature and the game code can access.

Can you provide an example? I know what a singleton is – What I’m asking is… what is even the object I am supposed to be interacting with? I want to change properties on my RenderPipelinesAsset scriptable object, but I don’t know what to reference. The RPA doesn’t have properties corresponding to RendererFeature.

Adapted from the linked site and not thread safe:

// Bad code! Do not use it!
public sealed class Scanline
{
    public bool isActive;

    //Private Constructor.
    private Scanline()
    {
    }
    private static Scanline instance = null;
    public static Scanline Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new Scanline();
            }
            return instance;
        }
    }
}

you can then access the isActive like this:
Scanline.Instance.isActive = true/false;
from any behavior on a gameobject

Keep the RendererFeature itself active and only in the RenderPass.Execute method, check for the isActive flag on the Scanline Singleton to blit or not to blit.

this way you don’t need to touch any instance of the PipelineAsset