I am attempting to create a save system but want as little intrusion as possible. I would like to do what EasySave does and that is, when I add a SaveGameObject.cs script to an object in the hierarchy, it will load all serialized fields from all other scripts attached to the object and add them as select-able fields to the SaveGameObject.cs.
I am terrible with custom inspector stuff but if I can just figure out how to get a list of SerializedFields from the other scripts, that would be a great start.
You’re looking at reflection. Find all public non-static fields and all non-public, non-static fields flagged with [SerializeField] attribute and oh wait don’t forget about skipping fields with [NonSerialized] attribute and don’t forget about looking in base classes, too.
This will quickly get pretty involved, and just saving all serialized fields just isn’t going to cut it for a savegame system. You also have to consider that at some point you’re going to make an update to your game and users will want to be able to load their old savegames despite the numerous changes you’ve made. But with this approach at that point you are in hell, because it’s either working weeks on the near unsolvable or face frustrated players (probably both because loading old saves is likely going to cause issues no matter how much work you put into that).
Meaning: you have to save data purposefully and with versioning. Non-intrusive savegame solutions, as in “plug and play” like EasySave, are effectively becoming broken solutions after you’ve released your game. They’re okay for quick & dirty or for development, but no more.