I'm making an open world game and it'll use the Dialogue System for each location. I'm already planning a map with 10+ locations and it looks like this:
What I'm currently doing is, every time you click on one of those location buttons, it does SaveSystem.LoadScene(sceneName); and there is one sceneName per location button.
Each of these scenes has a LOT of duplication in it though. They all look like this:
They'll differ by having different interactive objects, different backgrounds (and placements), and different characters (with different dialogue), but otherwise they'll be the same. I'm concerned that something could come up in the future that requires me to change each scene one by one. It's not the end of the world, but if I have to do that 3 times, it's going to be a pain.
I asked around on discord for advice, and some people came up with an idea I think is really cool. I could have a "main" scene that has all the things in common in it (like the Dialogue Manager, the HUDCanvas, etc.) and then I could have a specific scene (like "CoffeeShop") that only has the differences (the background, the characters, and interactive objects).
But, to do this, I'd need the main scene and the specific scene (e.g., "CoffeeShop") to be loaded together additively. Then when you change scenes, only the specific scene would be swapped out. For example, It would be "main" and "CoffeeShop", then when you change to "pigsty" it would be "main" and "pigsty".
It doesn't look like the SaveSystem can do this (but I could be wrong). But, is this main/specific scene idea a good one or is there a better way to approach this?
Should I have one master scene, a scene per location, or...
Re: Should I have one master scene, a scene per location, or...
Additive scene loading is a good approach for that.
It's coming to the Save System in version 2.1.7.
Technically you can do it now. Tick the Savers' Restore State On Start. Then use the regular SceneManager.LoadScene:
But when you save the game it won't save which scene(s) have been added to the main scene.
In version 2.1.7, SaveSystem will have AddScene and RemoveScene methods that take care of all that.
It's coming to the Save System in version 2.1.7.
Technically you can do it now. Tick the Savers' Restore State On Start. Then use the regular SceneManager.LoadScene:
Code: Select all
SceneManager.LoadScene("pigsty", LoadSceneMode.Additive);
In version 2.1.7, SaveSystem will have AddScene and RemoveScene methods that take care of all that.
Re: Should I have one master scene, a scene per location, or...
A Saver component typically only does work in reaction to two events: RecordData and ApplyData.
The Save System tells it to RecordData when saving a game and just before changing scenes. This method returns data that the Save System can store in its current game state data. For example, say a Harpy has moved from its original position to a nest in the back of the barn. In RecordData, the Position Saver would save its new position.
The Save System tells it to ApplyData when loading a game and just after changing scenes. This method receives data that it uses to restore its state. When loading a saved game or returning to the barn scene, the Position Saver would move the Harpy to the next in the back of the barn.
If you additively load a scene using SceneManager.LoadScene, a Saver component in the added scene won't know to restore its state from the Save System's data. The Harpy will stay in its original design-time position instead of going to the position where it was last recorded.
The Restore State On Start checkbox tells the Saver component's Start() method to restore its state from the Save System.
The Save System tells it to RecordData when saving a game and just before changing scenes. This method returns data that the Save System can store in its current game state data. For example, say a Harpy has moved from its original position to a nest in the back of the barn. In RecordData, the Position Saver would save its new position.
The Save System tells it to ApplyData when loading a game and just after changing scenes. This method receives data that it uses to restore its state. When loading a saved game or returning to the barn scene, the Position Saver would move the Harpy to the next in the back of the barn.
If you additively load a scene using SceneManager.LoadScene, a Saver component in the added scene won't know to restore its state from the Save System's data. The Harpy will stay in its original design-time position instead of going to the position where it was last recorded.
The Restore State On Start checkbox tells the Saver component's Start() method to restore its state from the Save System.
Re: Should I have one master scene, a scene per location, or...
Are you saying the Saver should be on every specific scene instead of in the main scene? Why shouldn't I put it on the main scene?
Re: Should I have one master scene, a scene per location, or...
I'm aiming for release on June 7 (a week from tomorrow) unless the target date slips for some unforeseen reason.
Re: Should I have one master scene, a scene per location, or...
Ah, cool. Thanks for letting me know. I'll probably just wait then.