Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Plugin which supports all pipelines: Standard, URP, HDRP

Discussion in 'Universal Render Pipeline' started by MUGIK, Jan 23, 2021.

  1. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    475
    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:
    https://gist.github.com/cjaube/944b0d5221808c2a761d616f29deaf49
    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?
     
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,236
    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:
    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.
     
    lilacsky824, MUGIK and Neto_Kokku like this.