Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

URP SetQuality - how to apply properly?

Discussion in 'Universal Render Pipeline' started by SamTyurenkov, Nov 30, 2019.

  1. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    84
    Here is what I have:

    In Player Settings - Quality tab, for each of the quality set I assigned a different URP asset.

    I have a menu button, which sets a Quality and expected behavior is to apply the desired URP asset as well.

    It works properly in editor. I can see that choosing low quality asset removes shadows, choosing high quality asset adds shadows. I also see that camera if selected in editor also changes the asset properly.

    But in an android build, the URP doesnt seem to change properly. I see some differences, but the shadows remain from the low quality asset.

    That was the first question. The second one is about post processing which is bound to camera now, it doesnt seem to be changing in both editor and build when a Quality choosen. How do I approach this one as well?

    Thanks!
     
  2. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    84
    Here is my code:

    Code (CSharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using UnityEngine.Rendering;
    5. using UnityEngine.UI;
    6.  
    7. public class QualitySet : MonoBehaviour
    8. {
    9.  
    10.     public Dropdown quality;
    11.     public Dropdown humanbot;
    12.     public RenderPipelineAsset lQuality;
    13.     public RenderPipelineAsset mQuality;
    14.     public RenderPipelineAsset hQuality;
    15.     private int v_quality;
    16.     private int v_humanbot;
    17.  
    18.     public void Start()
    19.     {
    20.         v_quality = PlayerPrefs.GetInt("Quality");
    21.         v_humanbot = PlayerPrefs.GetInt("HumanBot");
    22.  
    23.         quality.value = v_quality;
    24.  
    25.         QualitySettings.SetQualityLevel(v_quality, false);
    26.  
    27.         if (v_quality < 2)
    28.         {
    29.             GraphicsSettings.renderPipelineAsset = lQuality;
    30.         }
    31.         else if (v_quality < 4)
    32.         {
    33.             GraphicsSettings.renderPipelineAsset = mQuality;
    34.         }
    35.         else if (v_quality < 6)
    36.         {
    37.             GraphicsSettings.renderPipelineAsset = hQuality;
    38.         }
    39.         humanbot.value = v_humanbot;
    40.  
    41.         if (v_humanbot != 0 && v_humanbot != 1)
    42.         {
    43.             humanbot.value = 0;
    44.         }
    45.  
    46.     }
    47.  
    48.  
    49.  
    50.     public void SetQuality(int qualityIndex)
    51.     {
    52.  
    53.         QualitySettings.SetQualityLevel(qualityIndex, false);
    54.         PlayerPrefs.SetInt("Quality", qualityIndex);
    55.  
    56.         if (qualityIndex < 2)
    57.         {
    58.             GraphicsSettings.renderPipelineAsset = lQuality;
    59.         }
    60.         else if (qualityIndex < 4)
    61.         {
    62.             GraphicsSettings.renderPipelineAsset = mQuality;
    63.         }
    64.         else if (qualityIndex < 6)
    65.         {
    66.             GraphicsSettings.renderPipelineAsset = hQuality;
    67.         }
    68.  
    69.     }
    70.  
    71.     public void SetHumanBot(int hbIndex)
    72.     {
    73.         PlayerPrefs.SetInt("HumanBot", hbIndex);
    74.     }
    75.  
    76. }
     
    Last edited: Nov 30, 2019
    IEdge likes this.
  3. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    84
  4. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    84
    I implemented another script:

    And again it works in editor, correctly disabling and enabling shadows. But in Android Build shadows are not affected.
    I still didn't find how to switch shadows on a camera itself.
     
  5. NateReese77

    NateReese77

    Joined:
    Jun 14, 2017
    Posts:
    26
    Hello - did you ever find a solution for this? I'm having trouble where the different URP settings work great in editor, but in builds they just default to a single one no matter what the quality setting.
     
  6. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    Hmm, I was hoping that we didn't need to assign to GraphicsSettings.renderPipelineAsset in script if we call SetQualityLevel, as there is a pipeline asset that can be associated with each quality level... but stepping through with the debugger, I see that renderPipelineAsset is not affected by SetQualityLevel o_O

    My current issue is that on some devices (iPad Air 1, A7), if I call SetQualityLevel (with applyExpensiveChanges true or false) all the opaque objects turn black after they are rendered (I can see this in the Frame Debugger)

    URP 7.3.1, Unity 2019.3.13f1
     
    Last edited: May 14, 2020
  7. frothypants

    frothypants

    Joined:
    Jul 23, 2016
    Posts:
    17
    Sorry to post on an old thread. Did any of you get this figured out?
     
  8. InteractivaStudios

    InteractivaStudios

    Joined:
    Apr 28, 2013
    Posts:
    19
    Same problem in Unity 2020.2.1. I guess the solution is to manually switch the URP asset like this video shows:

     
    RealPowerPaul likes this.
  9. raysainthyl

    raysainthyl

    Joined:
    May 8, 2019
    Posts:
    7
    unfortunately:( the method using by this video does not work for 2D Renderer Data