Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Platform dependent compilation

Discussion in 'Graphics Experimental Previews' started by kripto289, Nov 2, 2018.

  1. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    509
    Hello,
    Is there a way to check which rendering version is being used? Default rednering or LWRP/HDRP?
    I write my own shaders for assetstore and want to do uber shader and script for different renderings.
     
  2. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Interested in having this info too. Did you find something?
    Thanks
     
  3. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    509
    Yes, I find.

    You can check the name of rendering
    Code (CSharp):
    1. var rpa = GraphicsSettings.renderPipelineAsset;
    2. Debug.Log(rpa.name);
    3. //This would print the name of the used SRP Asset. ie: LWRP-HighQuality, LWRP-LowQuality, LWRP-MediumQuality, HDRenderPipelineAsset
    and then you can use define symbols of unity editor (editor -> settings -> player -> other -> script define symols

    I use it for change my shaders for lwrp/hdrp in runtime.
     

    Attached Files:

    stephero likes this.
  4. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Many thanks for the info and for the code snippet. I am not a big fan of comparing asset name strings like this:
    Code (CSharp):
    1. if (rpa.name.ToUpper().Contains("LWR")) return FX_RenderingType.LWRP
    But I don't see any other ways.

    Did you find a way to access the HDRP or LWRP version to know if the user has the version 3.2.0 or 3.3.0 of the package for example? Couldn't find any variables in the SRP API about it, even if it seems like a very basic info to provide.
     
  5. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    509
    You can check the version there
    "unity folder\Packages\manifest.json"
    or using native unity file "packages->lightweight RP->package.json" (but I don't know how to read this file using c#"
     
    stephero likes this.
  6. alexrau

    alexrau

    Joined:
    Mar 1, 2015
    Posts:
    80
    Is there a way to do this instead with Platform Specific includes, so that if it is a line a code that won't compile if UDP/HDRP is pipeline.
    For Example:

    #if HDRP_PIPELINE
    // Do HDRP stuff
    #endif