I have separate external events for LOAD and SAVE which are included in the beginning and end of the scene respectively. However, I am facing random issues like data not updating to/from storage, conflicts between scene variables and global variables and therefore I seek your inputs on understanding the recommended practice to load/store values in Storage.
I have tried following options for Load/Save:
LOAD
Option 1: Load values from storage in a temporary scene variable, and then use that variable in the scene and update its value accordingly.
For example: Load “ExampleValue” from storage “ExampleStorage” and store value in ExampleValueTemp. In this case ExampleValueTemp will be used only during the data loading and nowehere else in the scene.
Option 2: Load values from storage in a temporary scene variable and then assign that value to a global variable and then use that global variable in the scene and update its value accordingly.
For example:
- Load “ExampleValue” from storage “ExampleStorage” and store value in ExampleValueTemp
- Change the global variable “ExampleValue” = ExampleValueTemp
- Use/Update global variable “ExampleValue” in scene as appropriate.
SAVE
Option 1: Save values of global variables directly to storage. For example:
Save GlobalVariable(ExampleValue) in “ExampleValue” of storage “ExampleStorage”
**Option 2:**Save values of global variables to a temporary variable and then use that variable to update values in Storage.
For example: -
- Change the ExampleValueTemp = global variable “ExampleValue”
- Save ExampleValueTemp in “ExampleValue” of storage “ExampleStorage”
I would like to load the data from storage only once(during game load/scene load or during special events) and save it only when the scene is complete or the game is closed or when special events are triggered (like setting change). This is to avoid too much read/write operation to the storage and use global variables as a placeholder to load/store values during game execution.
Are there any specific scenarios where a particular combination of Load/save would be helpful? Or any other suggestions on how to do it more effectively.
Would there be any conflicts in the above setup if I Load/Save data from/to storage in a separate events and then include those events in the scene?
Any reasons why, by design, data from storage can only be loaded to scene variables?