I have a question
Is there a way to save all Variables from a Actor. And load them after the game is Restart?
Without which I have to enter all the single?
Maybe with Get all actor with Interface (SaveData)
And then save all the variables from this actor with this interface?
How do I do this and how do I then recharge all?
I can not find anything on the Internet looking for several days
I would do it like this:
Create a custom C++ SceneComponent. This component has a string property representing a filename.
To save the actor’s data, the SceneComponent will iterate through the actor properties using a UProperty iterator.
For every primitive property, transform the values into a string.
For every actor property, get the class and tag and make a string out of them.
Concatenate all strings.
Write this string to disk at the filename.
Saving can be triggered on a user action or if you want to make it really fancy, there are some functions that get triggered when properties change their values. Read " How to handle property updates in code? ".
To retrieve the values, the SceneComponent will get the file from filename, parse the string and write the values back into the actor properties. For the actor properties, use the class and tag to find the actor in the scene.
Add the SceneComponent to all actors that need to remember their property values.
This is a generic solution and it only makes sense to use it if you have a lot of objects that need to remember their values. If you just need to save values for a single or a few objects, you could use the “Save Game to Slot” and “Load Game from Slot” nodes.