Switch Renderer in RenderPipelineAsset at runtime / from script ? [SOLVED]

I want to achieve a “highlight” effect where a selected object is rendered differently than the rest.

What I have done is creating two different ForwardRendererData Assets:

So far so good, the different renderers work as expected, but I have no clue how I can switch the default (or current active) ForwardRendererData from a script (e.g. when the user selects/deselects an object).

I can get the active RenderPipeline Asset from QualitySettings.renderPipeline but the API is unclear for me as to how I would access the “Renderer List” as shown in the Editor (Screenshot above).

I could be hacky and use different Quality Levels and manually assign RenderPipeline assets to them which either have the normal or highlight rendering, and then switch the quality level from script… but I dont think that would be the best solution.

Thanks for any input!

5158970--511241--upload_2019-11-9_23-37-32.png

I found a solution… not very intuitive but hey.

The following code is only for testing the toggle of the renderer

var x = GetComponent<UnityEngine.Rendering.Universal.UniversalAdditionalCameraData>();
if (Input.GetKey(KeyCode.LeftShift)) x.SetRenderer(1);
else x.SetRenderer(0);
3 Likes

Thanks for that… I’ve been looking into this as well.

It makes me wonder what the intent is for having a list of renderers. From what I’ve seen, there’s no order/sequence - it seems only the “default” renderer is active at one time.

I had initially hoped that it would allow for additive-like behaviours where you can add multiple renderers and simply toggle the ones you want to active at any given time.

In your example, if I want highlighting turned on, then I would just toggle that renderer to be active.

Instead it seems like this list of renderers is really just a holder for all possible renderers in your game and it’s up to you to switch things around. But the way it’s done that is not the greatest. Somewhere in the code you will need to associate “0” with one renderer and “1” as the other - nasty.

Wow, you are my savior! I spent 3 hours trying to figure out how to switch that when I found this page. Thanks!