I figured out how to make certain objects like my Camera and Canvas
persist across scenes, but I can't figure out how to access them in
the editor from scenes in which they're not instantiated.
A scene is basically a collection of objects (and serialized properties) that the engine bundles and can load together. As such, it's allowed to cross reference objects that belong to the same scene.
DontDestroyOnLoad mark an object in such a way that when a non additive scene loading operation(Apllication.LoadLevel|LoadLevelAsync) is performed, that object won't be destroyed. It controls the runtime lifetime of an object. In editor mode, isn't possible to reference an object across different scenes.
I can make these objects prefabs and make my changes to the prefab
rather than the instance, but then I can't make references in the
prefab to objects in the hierarchy; I would have to use an instance of
a prefab to do that.
That's how it works, right. If you want to setup references in one of your persistent object you basically have 2 ways:
- Instantiate (or save it into a scene) once, prevent it gets destroyed(DontDestroyOnLoad), and initialize reference at runtime when a different level is loaded (es. OnLevelWasLoaded)
- Save a prefab instance of such objects in each scene, and serialize references you need into the relative instances.
How can I edit subsequent scenes in the same way that I edited the
first scene, where all the DontDestroyOnLoad objects are instantiated
for the first time and I can access them through the hierarchy?
If you are asking how to reference in a Scene_B
a prefab is supposed to be instantiated and not destroyed in a Scene_A
, in editor mode
then you can't.
The object instance is only available when a particular scene will be loaded (at runtime or in the editor for editing)