Attempting to save an abstract datatype.
I have made most of a game and am now attempting to set up the save system. I get error message:
SerializationException: Type 'Item' in Assembly 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
'Item' is a public abstract class that I made to define everything to be considered items in the game. According to the UnityDocumentation an abstract type cannot be serialized. I am at a loss because I need to save the player's inventory (represented as an array of items).
As I see them, my options are to either:
Rework the factory that I have made to create Items.
Give each type of item a unique Identifier and then save and load that unique number turning them back into items.
Either one will take a fair amount of time to make and ensure functionality (as almost every change does) But I'm hoping someone who has run into this problem before knows how to plan around it or can tell me that I'm wrong and the solution is very simple.
Your answer
Follow this Question
Related Questions
Serialize Data on iOS in persistentDataPath 0 Answers
How to serialize/save a vector3 without all decimals? 1 Answer
problem with loading data with serialization in the right time 0 Answers
Serialize gameobject children behaviours 0 Answers
ScriptableObject created from custom editor lose data on Unity restart 1 Answer