Syncronizing inventory between objects

Options
I have objects that acts as containers (chest, boxes, ammo boxes, etc) and they have an array of ItemData which is a simple class like this
[System.Serializable] public class ItemData {
public Item itemGameObject; // Monobehavior with the prefab properties like name, Sprite for UI, etc)
public int amount; // If the item is stackable I store it here
}

So when a player interacts with the container, only he can take or store items there. Other players must wait for him to leave the chest. The method to store items looks like this:
[PunRPC]
public void StoreItem(ItemData item) {
}

But when I call the object with
container.photonView.RPC("StoreItem", RPCTarget.All, item);

I get this error
Exception: Write Failed. Custom type not found: ItemData

Which I saw PUN can't serialize complex objects. But how else can I update an object like a container? I previously used ScriptableObjects where all the properties were stored but I received the same error. What Im thinking to do is create a separate object as a singleton that loads all the items in the Resources folder and retrieve the item data from there to display the ui sprite, name, description, etc. As my game is not planned to be as big as an open world with hundreds of items I still think this is a "heavy" solution to take. But I cannot think in a better one

Comments