I have a project with three cameras. The main camera (skybox) is for the scene, and one of the other cameras (depth only) shows just one object in its own layer. I need to enable the second camera as needed to show that one object, and at the same time disable the main camera so there’s nothing in the background.
This works fine in Unity. But in a web player or standalone, the display goes crazy when I disable the main camera. You can still see the rest of the scene (which should be gone), but the object in the second camera view just keeps drawing over and over as it moves. The moving objects in the third camera’s view do the same. Kind of looks like an animation where every previous frame draws along with the current frame. Like trails. After a while, if I let it go, the screen just starts flashing randomly. Doesn’t matter if I disable the main camera by setting active to false or enabled to false.
I can work around this, but I’d like to know if I’m doing something wrong. Can you not disable the main camera?
You can disable whatever you want. If you don’t render something, however, you’ll get the same behavior as not having any objects in the frustum, and setting a single camera’s clear flags to “Don’t Clear”. It’s just the garbage from the color buffer. It’s probably gray in the Editor because the Scene View has a gray background – who knows.
The solution is to have your lowest-depth camera not use “Don’t Clear” or “Depth only”.
The manual put it a lot more succinctly. “Don’t Clear”.
some scripts call the currently tagged camera as a main camera instead of reference an exact camera,
so some scripts depend on it to be a camera tagged as main camera
i dont know if the skybox is the case, because i use a custom made skydome…
some character controller scripts depend on a camera to see where the character should be looking…
if you are switching cameras,if theres needs to be a main camera because some of your script, just tag the new camera as main camera, and disable the previous one so theres always a main camera, if theres multiple cameras at the same time rendering in diferent viewports, and for example it needs a camera in a script as i mentioned before for a character, you should make that script select the most appropriate camera to use for the looking and stuff like that, but no, theres no need for a camera tagged as main camera, but as i said, you need to make sure no script makes a call for it