Disabling a SkyBox with code


Sorry this is probably a really basic question - I’m not a programmer, just doing my best to create a AR App. I’m using the Vuforia AR SDK to detect a few targets - one of the targets I want to have a SkyBox on so what I’ve done is add a skybox to the camera. Obviously this means it’s persistent, so I was hoping someone could suggest how I enable it/disable it with code. Below is where I add the code where it detects different targets, is there a way to just set the SkyBox to visible = true/false?

switch (component.gameObject.name) {
			case "Earth":

Any suggestions would be greatly appreciated.


Try putting a script on the camera (if the SkyBox is camera specific) and changing it’s gameObject.active.

If that doesn’t work, make two cameras, of which only one has a skybox and switch between them (I know it’s a PITA).

Or use a script to change the material of the skybox component on the camera through a script.

You just need to get the Skybox component from the camera and disable it.

someCam.GetComponent<Skybox>().enabled = false;