Hi, my name is Vincent Prom, and this is how to save runtime changes to variables into the editor.
(This is useful when handling large amounts of data that you can only calculate during runtime. In my case, I needed to store a large amount of huge arrays which I could only produce by moving the character in specific ways.)
Normally, you would use SaveGames to save changed variables and then load them whenever necessary to get those values back. However, you can't package a SaveGame .sav file, not easily atleast. Packaged builds won't be able to access the SaveGames we make in editor.
So, here's the workaround.
Here I've make a widget that creates an array of 100 random integers. I can also print whatever is stored in the "IntArray" variable.
Here you see it working, but if I restart the PIE, it will not print anything, since runtime changes are not saved.
In order to save runtime changes, we still use the SaveGame class. I'm gonna make a new SaveGame. In it, I'll create a variable of type int array. If you need to store more than one variable, I recommend you create a struct variable instead.
Now I'm going to make it so whenever I generate Ints, they get saved into a SaveGame of the class I just made.
Finally, in order to access the generated values, I'm going to make a "getter" actor. In the getter's Construction script, I'll load in the Save slot, get the variable, and set it to an exposed variable in the getter.
Now in PIE, I'll generate an array of ints.
Close the PIE.
And now I can access that array using the getter. I can copy the variable... and paste it anywhere else.
Ещё видео!