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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Question VolumetricClouds: changing preset via script

Discussion in '2022.2 Beta' started by ashtorak, Jul 19, 2022.

  1. ashtorak


    Feb 19, 2014
    In 2022.1 I used the way below to change the preset, but it doesn't seem to work anymore. While the preset value itself does change in the inspector, it doesn't load the preset's values.
    Has there changed something or is my project bugged? Or is it a general bug even?

    Code (CSharp):
    1. public void setCloudPreset(int i)
    2.     {
    3.         VolumeProfile profile = globalVolume.sharedProfile;
    4.         profile.TryGet<VolumetricClouds>(out var clouds);
    5.         VolumetricClouds.CloudPresetsParameter cp = clouds.cloudPreset;
    6.         cp.value = (VolumetricClouds.CloudPresets)i;
    7.     }
    Last edited: Jul 19, 2022
  2. ashtorak


    Feb 19, 2014
    So I have made a new project with a global volume with volumetric clouds and attached this script, but it still doesn't work:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Rendering.HighDefinition;
    3. using UnityEngine.Rendering;
    5. public class test : MonoBehaviour
    6. {
    7.     void Start()
    8.     {
    9.         VolumeProfile profile = GetComponent<Volume>().sharedProfile;
    10.         profile.TryGet<VolumetricClouds>(out var clouds);
    11.         clouds.cloudPreset.value = (VolumetricClouds.CloudPresets) 2;
    12.     }
    14. }
    It changes the preset from Sparse to Overcast, but the parameters don't change:


    So how to do it now or is it a bug? Then I can submit it.

    Attached Files:

  3. ashtorak


    Feb 19, 2014
    I filed a bug report which is now under investigation.
    As a workaround I now use a game object for every cloud preset and just enabled/disable the objects. Works also fine :)
    x1alphaz1 likes this.