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
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question VolumetricClouds: changing preset via script

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

  1. ashtorak

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53
    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

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53
    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;
    4.  
    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.     }
    13.  
    14. }
    It changes the preset from Sparse to Overcast, but the parameters don't change:

    upload_2022-7-27_17-55-2.png

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

    Attached Files:

  3. ashtorak

    ashtorak

    Joined:
    Feb 19, 2014
    Posts:
    53
    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.