Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

[Solved]Can't update color in GradientSky on post process volume by script

Discussion in 'Scripting' started by wenzy, Oct 19, 2020.

  1. wenzy

    wenzy

    Joined:
    Nov 17, 2015
    Posts:
    34
    Hello community,

    In HDRP's Volume component, I want to lerp the color in gradient sky by script.

    I have set the UpdateMode to "realtime" and the Update Period to "0",

    and here is my script:


    Code (CSharp):
    1.   public GradientSky daySky;
    2.     public Volume vol;
    3.  
    4.     void Start(){
    5.         vol.profile.TryGet(out daySky);
    6.     }
    7.  
    8.     void Update(){
    9.  
    10.          daySky.top.value = Color.Lerp(Color.white, Color.black, (Mathf.Sin(Time.time * 0.4f) + 1f) / 2f);
    11.  
    12.      }
    I can see the "top color" is update in the inspector, but in the game scene nothing happen.

    HDRP version 7.31

    (PS: Update. The issue has solved when I update the HDRP version to 7.51)
     
    Last edited: Oct 20, 2020
  2. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    1,130
    I would love to help you, seeing that nobody replied, but frankly, I have zero experience with HDRP, so whatever I might tell you would likely mislead you.
     
  3. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    1,130
    Dumb question: Have you set the Sky type to Gradient Sky in Visual Environment panel?
     
  4. wenzy

    wenzy

    Joined:
    Nov 17, 2015
    Posts:
    34
    Thank u. Yes. If I don't use script. I can change the gradient color and it can affect the game scene
     
  5. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    1,130
    So it was a bug after all (after seeing your OP edit). I wanted to suggest it, but I wasn't sure enough.
     
unityunity