- Home /
Disabling a SkyBox with code
Hey,
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":
component.gameObject.animation.Play();
component.gameObject.audio.Play();
break;
}
Any suggestions would be greatly appreciated.
Chris
Answer by jaskij · Sep 06, 2012 at 04:19 PM
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.
Answer by AndyMartin458 · Nov 08, 2016 at 02:14 PM
You just need to get the Skybox component from the camera and disable it.
someCam.GetComponent<Skybox>().enabled = false;