Skip to main content
10 events
when toggle format what by license comment
Feb 10 at 14:59 comment added Pow Sounds good, appreciate the help. I'll try to implement it.
Feb 10 at 14:58 comment added DMGregory That's a different question, unrelated to how to serialize a list of different types. I don't recommend auto-registering every instance for saving though, as your users will likely want to have control over which things get saved (e.g. if they construct temporary instances, or create and destroy instances frequently, they don't want all of them automatically adding themselves to save files and bloating the storage)
Feb 10 at 14:56 comment added Pow Yeah i'll do that, but just incase, do you know if I could do that with some kind of attribute maybe? I just want to make it as easy to understand as possible.
Feb 10 at 14:52 history edited DMGregory CC BY-SA 4.0
Adding example API methods
Feb 10 at 14:37 comment added DMGregory Right, but that's the responsibility of the folks using your asset. You just give a public void AddDataToSave(ISavable data) method, and they call that and pass in the things they want saved. I've updated the demo above with a pair of such API methods.
Feb 10 at 14:34 comment added Pow Ah, ive noticed one issue with this solution, when you use the "add mixed types" function, you know what classes to add, in my case, since I'm releasing this for the Unity asset store, I need any class, struct, etc, thats derives from "Savable" to be able to be added to this list when saved and then serialized.
Feb 10 at 14:20 history edited DMGregory CC BY-SA 4.0
Adding details on iterating the loaded list
Feb 10 at 14:10 vote accept Pow
Feb 10 at 14:10 comment added Pow Whoops, I just made a new question about that, but thanks for the info that will definitely be useful. Hopefully someone can help me out with encrypted and serializing the data. I also notice you've used System.Object which makes sense, I noticed after that all types derive from it.
Feb 10 at 14:00 history answered DMGregory CC BY-SA 4.0