- Home /
How can I refer to physically based sky script?
Hey there! I'm currently trying to refer to the physically based sky script to change the rotation of the space. Anyone knows how could I do that?
Answer by Padawaan · Feb 02, 2021 at 11:03 AM
Hey I wanted to do the same thing and the only way I've found is this one:
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
Volume nightVolume;
PhysicallyBasedSky nightSky;
//where needed, access it like this
if (nightVolume.sharedProfile.TryGet(out nightSky))
{
Vector3 current = nightSky.spaceRotation.value;
current.z += Time.deltaTime * spaceRotationSpeed;
nightSky.spaceRotation.value = current;
}
Be sure to get the 'sharedProfile' of the volume, otherwise it looks like using 'profile' will return a copy.
If it's possible, it might be a good idea to cache it instead of calling the TryGet() everytime...
I've found this method in this thread: https://forum.unity.com/threads/hdrp-2019-1-how-do-you-change-effects-volume-overrides-through-script.668842/
Answer by traisjames · May 30 at 06:14 PM
I am trying this method out, but at the if statement, I get the error "NullReferenceException: Object reference not set to an instance of an object" in unity. I am running 2021.3.3f1 incase version is important.
Your answer
![](https://koobas.hobune.stream/wayback/20220613024241im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation scripting 1 Answer
Can't activate my timer for shooting script? 2 Answers
Assign EventTrigger reference Script at Runtime 1 Answer
[Probably an easy question]Troubles saving my GameObject through scenes 1 Answer
Is there any overhead when using Update functions for making object references? 1 Answer