Creating a Save File
Last updated
Last updated
Skip this process with .
We know that you can create a save file using the component. Alternatively, you can create a save file through code.
A save file needs save file setup data to be created. The code below creates save file setup data.
However, this code will not create an encrypted save file.
The only supported encryption method at the time was AES. To create an AES-encrypted save file, we would need an AES key and IV. These are used for the AES algorithm. Both the AES key and IV are just a string of random alphanumeric characters. It is recommended that they be at least 16 characters in length.
The key and IV of a save file must not change, as the same key and IV are required during both encryption and decryption. So, we should create constants that we will use every time.
The key must be 16, 24, or 32 characters in length. The IV must be 16 characters in length.
If you'd rather not write a random string, you have the option of using key and IV generation methods—however, these methods generate a new key and IV each time.
You can come up with your own solution for reusing them. One way would be to debug the string in the console, copy it, and then paste it in a string variable.
This will be similar to the previous one, except we will change the encryption method to AES and provide the key and IV.
After using the code below, you have successfully created an encrypted save file.
To create a save file that will save and load data in the background, set the backgroundTask
value to true.
You can set this value at any time during runtime, and the save file will use a background or main thread accordingly.