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

Question How to get/know the properties of a URP asset in script?

Discussion in 'Editor & General Support' started by Aviation_Simmer, Dec 29, 2022.

  1. Aviation_Simmer

    Aviation_Simmer

    Joined:
    Aug 30, 2021
    Posts:
    110
    Since its very important for a game to have settings, I am also working on that. Since my flight simulator is a very "heavy" game. I have set Playerprefs with the values, I need. Now I just need to apply them to the urp asset. but how?

    Code (CSharp):
    1.     void SetDisplayGraphics()
    2.     {  
    3.         GetSavedData();
    4.         var urprender = GraphicsSettings.renderPipelineAsset; //Get the current active URPrender
    5.  
    6.         //HDR has a stored value, 0 and 1 for false and true.
    7.         bool hdr = HDR == 0 ? false : true; //converting from 0 & 1 to false & true.
    8.         urprender.hdr = hdr; //if "hdr" is not correct, how should I know?
    9.     }
    I am using:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.Rendering;
    6. using UnityEngine.Rendering.Universal;
    7.  
    And i was looking for urp asset properties and found that:
    https://docs.unity3d.com/Packages/c....universal@13.1/manual/universalrp-asset.html
    I have tried with a few typical variations but none of the properties worked..


    the error: 'RenderPipelineAsset' does not contain a definition for 'hdr'...
    thanks! upload_2022-12-30_0-28-20.png
     
    Last edited: Dec 29, 2022
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
  3. Aviation_Simmer

    Aviation_Simmer

    Joined:
    Aug 30, 2021
    Posts:
    110
    After looking for a while I still havent found a solution... so now it looks like this:
    Code (CSharp):
    1. urprender.supportsHDR = hdr;
    But I also have tried many other nonesense stuff...