HDRI Sky cannot be disabled ?

Hello everyone,

This might be a dumb question, I'm using HDRI Sky for the first time and I created an empty GameObject and attached a Volume and HDRI Sky to it as in the photo below, at some point in execution time, I want to change the HDRI sky and all I need to know is how to disable the HDRI Sky component.


To disable the HDRI Sky component attached to a GameObject during runtime, you can use the following code:

using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

public class DisableHDRI : MonoBehaviour
// Reference to the HDRI Sky component
private HDRISky hdriSky;

private void Start()
// Get the HDRI Sky component attached to the GameObject
hdriSky = GetComponent();

// Method to disable the HDRI Sky component
public void DisableHDRIComponent()
if (hdriSky != null)
// Disable the HDRI Sky component
hdriSky.enabled = false;

Here's how you can use the code:

  • Attach the DisableHDRI script to the GameObject with the HDRI Sky component.
  • During runtime, whenever you want to disable the HDRI Sky component, you can call the DisableHDRIComponent() method on the script attached to the GameObject.

By setting the enabled property of the HDRI Sky component to false, you effectively disable it and prevent it from affecting the scene's lighting. It may helpful for you.

Try to compile this script before. I wrote the same thing but trying to GetComponent of type HDRISKY is not possible.