Plugin which supports all pipelines: Standard, URP, HDRP

Hi everyone.
I’m trying to create an asset for the Asset Store, that will work with Standard, URP, and HDRP pipelines.
And I would like to know best practices and know-how on this topic.

What I already have is this script, which sets the project’s defines according to the currently active pipeline in Graphics settings:

which allows me to run the right code for different pipelines.

Problem:
I use Assembly Definition files (.asmdef) to structure code.
My code needs references to URP features. So I need to reference “Unity.RenderPipelines.Universal.Runtime” assembly. But this assembly might not be present in the project (which is logical, if project uses Standard pipeline).

The same problem with HDRP.

Any ideas on how to solve this situation?

Since 2019.1 references to other assemblies are done based on GUID, meaning if one is missing, it is no longer referenced and won’t throw any errors. 2019.1 would need to be your minimum supported version in this case.

In your own assembly, you can set version defines, which are enabled only in your assembly if a package matches or exceeds the version number you set. You can use these in C# just like regular define symbols:
6759082--780247--upload_2021-1-24_12-53-5.png

This way it’s not necessary to add global define symbols to a project, which have the disadvantage of staying there, even if the related package is uninstalled, causing a shower of errors.

3 Likes