- Home /
Unity HDRP: How to rotate the skybox
With the new Unity HDRP the skybox and environment settings from the lighting bar have disappeared and made way for a different way to tackle these, with the Volume Settings gameobject.
Is there a way to call the rotation value from this gameobject in code? I mean the rotation knob thing not the game object rotation itself as it would just rotate the gameobject and not the skybox itself.
Answer by David2022 · Jan 30, 2020 at 12:17 PM
public Volume volume;
private HDRISky hdriSky;
private float hdriRotationSpeed = 20;
private float rotation = 0;
void Start() {
volume.profile.TryGet(out hdriSky);
}
void Update()
{
if(Input.GetMouseButton(1)) {
if(Input.GetKey(KeyCode.LeftAlt)) {
float angle = Input.GetAxis("Mouse X") * hdriRotationSpeed;
rotateHDRI(angle);
}
}
}
private void rotateHDRI(float angle) {
rotation += angle;
while(rotation > 360) {
rotation -= 360;
}
while(rotation < 0) {
rotation += 360;
}
hdriSky.rotation.Override(rotation);
//hdriSky.rotation.value = rotation;
}
With this script you can rotate the hdrisky by pressing right mouse button + left alt and moving the mouse. hdriSky.rotation.value = rotation; does not work for me, but i saw it in other answers to same questions.
Your answer
Follow this Question
Related Questions
crossfade between skyboxes 1 Answer
how do you make sky boxes 1 Answer
How to not let Child object rotate with Parent 1 Answer
Two Skyboxes 1 Answer
Skybox not seamless (enough) 1 Answer