Question by
Caliber · May 03, 2018 at 08:57 AM ·
c#serializationscriptableobject
Serialize a list of class containing ScriptableObject assets
My code looks something like this:
list<InventoryItem> inventory = new list<InventoryItem>();
[Serializable]
public class InventoryItem
{
public Item item; // Items are ScriptableObject assets
public int quantity;
}
What is the proper way to serialize list inventory?
As I understand it, I should serialize a reference to the Item, rather than the Item itself, but I've been unable to figure out how, and haven't found any examples.
Comment
Your answer
Follow this Question
Related Questions
[SOLVED] ScriptableObject generic list makes all derived instances to base type when serializing 1 Answer
Serializable Class On ScriptableObject Null when loaded from AssetBundle 2 Answers
Can I implement generics to create objects that each work with a different class. 0 Answers
How to write a Story Event System with ScriptableObjects? 0 Answers
Using dictionaries in scriptable objects to store crafting recipe's 0 Answers