Saving Player Created Storage

siendel

New member
So I have the inventory saving working for scene items, and I've modified the UIS save routine to also add saving for some player attributes (position, rotation, etc.) and for all player crafted items. I also want the ability for the player to create one or more storage chests at runtime. I can incorporate this into my player crafted load/save routine which will create a storage chest (using a deactivated prefab in the scene to clone from). Putting items into that chest, saving, and loading works if I start with it already in the scene. But, how would I go about saving/loading the inventory from the runtime created chest(s)? I have the system creating my player items first, before the inventory savers start loading. Is there a way (i.e. what parameters need to be set) for the UIS saver to think the newly created chest inventory was the same one it saved from? The chest names are unique (includes an ID number in the name string) and that will match from save to load (in addition to position/rotation). Is there any other property that needs to be identical?

Thanks
 
The Saver system uses a FullKey to map save data to an object.
The full key is defined as such: <game object name>_<Saver type>_<Key>
Code:
public virtual string FullKey => string.Format("{0}_{1}_{2}", new object[] { gameObject.name, this.GetType(), m_Key });

1613981310647.png

Meaning that if the game object name is unique it should be saved and loaded correctly. If you want to be extra sure that they are different you may add a Key value.

I hope that makes sense
 
That you very much for the rapid response, as always! I just tested this and it works fine :) I can click on the chest in my inventory, 'Place' it on the ground, put something in it, quit, reload, and the chest spawns correctly along with the inventory items. Exactly what I needed!

The same functionality I would assume would work for any other spawned inventories, such as spawn-able enemies that might have items in their inventory stolen. Really impressed with how easy it's been to work with the UIS so far.
 
Top