- Home /
Is there any way to test to see if the project is uing the URP/HDRP?
I'm creating an editor script that creates materials from textures, I use something like:
Material mat = new Material(Shader.Find("Standard"));
However if the user is using URP or HDRP then I need to use:
Material mat = new Material(Shader.Find("Universal Render Pipeline/Lit"));
Is there some way I can do a check to see if they are using the URP/HDRP?
Answer by BastianUrbach · Feb 16, 2021 at 06:41 AM
You can get the name of the active RenderPipelineAsset with
UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset.GetType().NameFor the Universal Render Pipeline for example this is "UniversalRenderPipelineAsset". If no scriptable render pipeline is used then renderPipelineAsset should be null.
Note that you can get the default shader and default material for the current render pipeline using
UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset.defaultMaterialand
UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset.defaultShader
Answer by NikiWalker · Feb 16 at 05:48 PM
@Snowdrama Here is a decent approach using Assembly Definitions (.asmdef's): https://forum.unity.com/threads/hdrp-lwrp-detection-from-editor-script.540642/#post-7901968
Your answer
Follow this Question
Related Questions
Material Validator in LightWeight Rendering Pipeline 0 Answers
LWRP: Set custom shader at runtime 1 Answer
URP material set texture scale 0 Answers
Using Color.Lerp with Lightweight Render Pipeline 1 Answer
change material on background 4 Answers