Hello everyone,
I have a dictionary that I want to serialize:
public Dictionary<int, Item> invBag
Where Item derives from MonoBehaviour. I’ve been reading a lot on Serialization and it looks like I can’t directly serialize Item. From what I can tell I then have a couple of choices.
- Use a Memento Pattern. (http://en.wikipedia.org/wiki/Memento_pattern). Where I would run through each Item in the dictionary, encapsulate that into a new Serializable class, put that into an array and serialize all of that. Then after we deserialize we load values back into dictionary.
- Unity Serializer. Looks like a very convenient option. I would like to understand this process more which is why I would like to try and avoid this.
- Build a Serializer. Probably beyond my abilities at the moment but I’m willing to look into it.
So my question is - am I missing something simple? Are these my only (reasonable) choices? I’ve already setup serialization for a simple class with basic Types (strings, int, float, etc.) but I’ve hit a roadblock with this.
Thanks all!