Search Unity

Question Best way to save/load multiple player inventories

Discussion in 'Scripting' started by Stoicheia, Dec 4, 2020.

  1. Stoicheia

    Stoicheia

    Joined:
    Jun 25, 2020
    Posts:
    27
    Hello Unity Forums,

    Let's say I have multiple characters in my game, each with their separate inventories. What is the best way to save and load this data using binary serialization or JSON or whatever? (not playerprefs or scriptable objects)

    For a single player we can store a list of item IDs and fetch the items from some database when we load from the save file. But since binary serialization doesn't serialize dictionaries, I'm not sure how you would handle that.
     
  2. AbandonedCrypt

    AbandonedCrypt

    Joined:
    Apr 13, 2019
    Posts:
    73
    Check out either Odin Serializer or JSON.NET, both can serialize generics including dictionaries. Odin is specifically tailored to Unity and can serialize virtually anything to JSON and bytestream.