I’m in the process of some tutorials. One has 3 prefabs. I placed 1 prefab in my initial scene. I enter each (2 more prefabs, see title of post), and add goodies such as VFX, lighting, etc. Whenever I hit “Play” it always uses the camera in the main being “VideoGameShop”. When I want to enter the other prefabs, it doesn’t allow me to use the camera within. So if I’m in Beachside prefab, and I hit “Play” it shows me to the Videogame Shop. Even if I put a camera in that prefab. Must I create individual unity files so I have one camera? Or how can I turn a Prefab into a scene? Currently I just double-click the prefab and edit.
Prefabs are just game objects you can copy and paste into scenes that have a ‘reference’ to their original asset, so the original prefab can be edited so that those changes proliferate across every other instance. Editing them is just an editor-only stage that isolates it from everything esle.
As far as the camera goes, Unity will use the first active camera starting from the active scene it finds. You can swap between camera via code by enabling/disabling the .enabled property of the camera component.
This is relatively independent of scenes. You can have scenes without cameras (and in most projects, this will be case).
It’s worth using the Cinemachine package to set up ‘virtual cameras’, which you can use to drive one regular camera by disabling and enabling their respective components. Needless to say all of this will require some level of coding.
Thank you! I learned a quick method (probably obvious but wasn’t for me). I just right-clicked the Prefab and turned it into a Scene. Then each scene could have it’s own independent camera. I was treating Prefabs like separate scenes when in reality they weren’t.
Another approach is to use additive scenes. For instance, in a lot of my games the player and camera are in one scene, and that scene is always additively loaded on top of the particular content scene for the level you are on right now, which I treat as the active scene for lighting and pathfinding purposes.
A multi-scene loader thingy:
My typical Scene Loader:
Other notes on additive scene loading:
Timing of scene loading:
Also, if something exists only in one scene, DO NOT MAKE A PREFAB out of it. It’s a waste of time and needlessly splits your work between two files, the prefab and the scene, leading to many possible errors and edge cases.
Two similar examples of checking if everything is ready to go: