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

Resolved PostExposure wont change even though the value changes.

Discussion in 'Universal Render Pipeline' started by Fuzzele, Aug 5, 2023.

  1. Fuzzele

    Fuzzele

    Joined:
    Jan 29, 2022
    Posts:
    3
    I have a script that changes makes a Slider change the PostExposure value on my ColorAdjustments override. It works, and the value changes but the actual exposure doesn't change. The value also only changes on the Unity UI when I click on and off of the game object. What am I doing wrong?

    void Start()
    {
    Volume Vol = GameObject.Find("PostProcessing").GetComponent<Volume>();
    ColorAdjustments adj;

    if(Vol.profile.TryGet<ColorAdjustments>(out adj))
    {
    ColorAdj = adj;
    }
    }

    (Code for getting the ColorAdjustments variable)

    public void ChangeBrightness(float value)
    {
    BrightnessSetting = value;
    ColorAdj.postExposure = new FloatParameter(BrightnessSetting, true);
    }

    (Code for changing the exposure when moving slider)
     
  2. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    257
    Use this code instead of instantiating a new FloatParameter (URP 14):
    Code (CSharp):
    1. ColorAdj.postExposure.overrideState = true;
    2. ColorAdj.postExposure.value = BrightnessSetting;
     
  3. Fuzzele

    Fuzzele

    Joined:
    Jan 29, 2022
    Posts:
    3
    This totally worked! Thank you so much.
     
    FaithlessOne likes this.