Issues loading prefab with custom inventory/item data/scripts

Discussion and help for Easy Save 3
Post Reply
Radicals
Posts: 8
Joined: Thu Jan 04, 2024 8:32 pm

Issues loading prefab with custom inventory/item data/scripts

Post by Radicals »

Hi there, I know this will likely be a case of "Please make a demo project you can share with me" but even that will be quite complicated.

The issue:
I am implementing ES3 into my game, which is a first person game with Tetris-inventory. My player prefab contains all of the inventory scripts and data in this (simplified hierarchy) below. Because I only really need to save the player's inventory data, I went with the approach of adding the "ES3Prefab" component to the prefab, which says it has found 529 references in the prefab. Cool.
I then went through all my custom classes and each reference to a custom class/struct/type I created, and put [ES3Serializable] in front of them.
I then hooked up a button to save and a button to load, to test it, but it does not save the inventory data. It is working because it moves the player transform to the position when it was saved, but their inventory data remains unsaved (or, unloaded).

Code: Select all

Player (Prefab)
<Components:>
PlayerEquippables  (What items the player has equipped)
PlayerInventory (Handles storing, adding and removing items to the player's inventory)
Come to think of it, those are really the only 2 key components on the root player gameObject that are crucial, the rest are all UI and other assorted things I don't need to save. I am just wondering what I may be doing wrong? I have added the Easy Save 3 Manager, whose ES3 Reference Manager has picked up the 1 prefab in the scene it needs to save ( "prefab count: 1").

My inventory items are a ItemSO (scriptableObject), which are instantiated as an ItemData class with a reference to the ItemSO. The player's equipped items are stored as a dictionay<SlotData, ItemData> where slotData is the player's slot (bag, helmet, primary, secondary, etc) I have added [ES3Serializable] to all the places I can think of, class headers, variable references to all my custom classes... Is that correct?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues loading prefab with custom inventory/item data/scripts

Post by Joel »

Hi there,
I went with the approach of adding the "ES3Prefab" component to the prefab, which says it has found 529 references in the prefab. Cool.
Just to check, you're adding this Component by right-clicking the prefab and selecting Easy Save 3 > Enable Easy Save for Prefab rather than adding it directly?
but their inventory data remains unsaved (or, unloaded).
Are you getting any warnings in console when loading? (you will want to check that warnings are enabled in console)

Also just to check, have you followed the Saving and Loading GameObjects guide? And specifically read the information regarding which Components will be saved by default, and how to choose which ones are saved?

https://docs.moodkie.com/easy-save-3/es ... ameobjects
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Radicals
Posts: 8
Joined: Thu Jan 04, 2024 8:32 pm

Re: Issues loading prefab with custom inventory/item data/scripts

Post by Radicals »

Just to check, you're adding this Component by right-clicking the prefab and selecting Easy Save 3 > Enable Easy Save for Prefab rather than adding it directly?
Yep, that's the way I did it.
Are you getting any warnings in console when loading? (you will want to check that warnings are enabled in console)
No warnings, no.
Also just to check, have you followed the Saving and Loading GameObjects guide? And specifically read the information regarding which Components will be saved by default, and how to choose which ones are saved?
Ah this might be it - I had assumed that adding "ES3 Prefab" component to the Player prefab root would "trickle down" to all the children. So I am guessing I need to add the "ES3GameObject" component as per the instructions, but I can't see that component in my auto-fill options (see pic) ?

es3.png
es3.png (17.69 KiB) Viewed 1555 times
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues loading prefab with custom inventory/item data/scripts

Post by Joel »

Are you using the latest version? ES3GameObject is only in the latest versions of Easy Save.
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Radicals
Posts: 8
Joined: Thu Jan 04, 2024 8:32 pm

Re: Issues loading prefab with custom inventory/item data/scripts

Post by Radicals »

Ah! Awesome, that was it - needed to update the package, now it's working, thank you!!
(To clarify, I updated, then added the ES3GameObject to the root Player gameObject and chose the components I wanted to save).
Post Reply