Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Cannot change HDRP Volume Fog through script

Discussion in '2019.3 Beta' started by Bordeaux_Fox, Nov 30, 2019.

  1. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Hello,

    I try to change the fog density in my HDRP scene with a script. I have a reference of the volume in a variable:

    Code (CSharp):
    1. if (Engine.sceneSettingsVolume.TryGetComponent<Fog>(out Fog fog))
    2.         {
    3.             oldFogDensity = fog.meanFreePath.value;
    4.         }
    But it throws that error:

    ArgumentException: GetComponent requires that the requested component 'Fog' derives from MonoBehaviour or Component or is an interface.
    UnityEngine.GameObject.TryGetComponent[T] (T& component) (at <7559bf9767e74ff5906f18401f66cd57>:0)
    UnityEngine.Component.TryGetComponent[T] (T& component) (at <7559bf9767e74ff5906f18401f66cd57>:0)


    So can't we access the fog settings at runtime? I have no problem to change other volume settings for example Motionblur. So then how we are supposed to do dynamic lighting and weather?